开发者

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

开发者 https://www.devze.com 2022-12-27 20:04 出处:网络
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.

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号