views:

182

answers:

1

I am writing a custom error handling/reporting function for php file upload and I noticed that the error codes returned is one of numbers 0 to 8 except 5.

Is this a typo in the source I am using or is it really this way? And if it is so, I am curious why they have skipped number '5'.

Thanks.

Edit In response to Pekka here are the error codes I found explained in my PHP manual.

UPLOAD_ERR_OK Value: 0; There is no error, the file uploaded with success.

UPLOAD_ERR_INI_SIZE Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

UPLOAD_ERR_FORM_SIZE Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

UPLOAD_ERR_PARTIAL Value: 3; The uploaded file was only partially uploaded.

UPLOAD_ERR_NO_FILE Value: 4; No file was uploaded.

UPLOAD_ERR_NO_TMP_DIR Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

UPLOAD_ERR_CANT_WRITE Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0.

UPLOAD_ERR_EXTENSION Value: 8; File upload stopped by extension. Introduced in PHP 5.2.0.

+3  A: 

It doesn't matter as you use the UPLOAD_ERR_* constants anyway. But I guess the field 5 was an error which is now handled by a different error case.

Edit

The case "5" was an error for empty uploaded files. However this isn't an error so the field/constant got removed. See changeset 81792 on main/rfc1867.c and changeset 88408 on main/rfc1867.c

Progman
Yes using constants is the way to go as the value may change some day. But, my question is `am I missing a case which may return error code 5?`
Majid
@Majid: no, its not defined (anymore), It might be defined in an earlier version but now the field is not used anymore and is not reused to prevent confusion about two cases getting the same index (and this way cannot be distinguished)
Progman