I am writing a custom error handling / reporting function for PHP file upload and I noticed that the error codes returned are numbered from 0 to 8 except 5.
Is this a typo in the source I am using or is it really this way? If it is so, I am curious why they have skipped number '5'.
Thanks.
Edit
In response to Pekka
, here are the error codes from PHP manual.
0 | UPLOAD_ERR_OK | There is no error, the file uploaded with success. 1 | UPLOAD_ERR_INI_SIZE | Size exceeds upload_max_filesize in php.ini. 2 | UPLOAD_ERR_FORM_SIZE | Size exceeds MAX_FILE_SIZE specified in HTML form. 3 | UPLOAD_ERR_PARTIAL | The uploaded file was only partially uploaded. 4 | UPLOAD_ERR_NO_FILE | No file was uploaded.5|UPLOAD_ERROR_E| As explained by @Progman, removed in rev. 81792 6 | UPLOAD_ERR_NO_TMP_DIR | Missing a temporary folder. 7 | UPLOAD_ERR_CANT_WRITE | Failed to write file to disk. 8 | UPLOAD_ERR_EXTENSION | File upload stopped by extension.
The error code can be found in the error segment of the file array that is created during the file upload by PHP. In other words, the error might be found in $_FILES['userfile']['error'] . Value: 0; There is no error, the file uploaded with success.
By default, PHP file upload size is set to maximum 2MB file on the server, but you can increase or decrease the maximum size of file upload using the PHP configuration file ( php. ini ), this file can be found in different locations on different Linux distributions.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With