$_FILES['file']['size'] echoing 0(zero) for files over upload_max_filesize
The problem is that I want to check if the file is too large to upload so that I can display a relevant error message, but when the file is larger开发者_运维问答 than upload_max_filesize in php.ini it seems to be only displaying a 0.
Why is this happening? How can I test that the file is too large to give a relevant error?
See http://php.net/manual/en/features.file-upload.errors.php
Relevant excerpt:
Since PHP 4.2.0, PHP returns an appropriate error code along with the file array. 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'].
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.
the fact that the file is present and saying 0 indicates that an error occurred... usually it's over the filesize limit. That's the relevant error.
edit: As the commenter below mentions, the relevant error is on $_FILES['userfile']['error'].
精彩评论