Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why file upload error codes in php miss number '5'?

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.
like image 514
Majid Fouladpour Avatar asked Apr 18 '10 12:04

Majid Fouladpour


People also ask

How will you access the error code associated with file upload in PHP?

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.

Can we upload file of any size to a PHP application?

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.


1 Answers

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

like image 93
Progman Avatar answered Sep 23 '22 02:09

Progman