Home » HTTP » HTTP_Upload » Bug #4441
inaccurate error when uploading large file
Details
| Submitted | 2005-05-26 13:42 UTC |
|---|---|
| From | glen at delfi dot ee |
| Assigned | antonio |
| Status | Closed |
| Package | HTTP_Upload |
| PHP Version | 5.0.4 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2005-05-26 13:42 UTC] glen at delfi dot ee
Description:
------------
i have file uploaded which exceeds the upload_max_filesize diretive
the object returns me NO_USER_FILE error. but inspecting $_FILES['userfile']['error'] it means that limit was reached instead.
and secondly there's new error type available since 4.3.10:
http://www.php.net/manual/en/features.file-upload.errors.php
Reproduce code:
---------------
set these php.ini variables:
post_max_size = 8M
upload_max_filesize = 2M
and upload 3MB file.
btw the $error is filled properly with TOO_LARGE constant and passed to HTTP_Upload_File()
$files[$formname] = new HTTP_Upload_File($name, $tmp_name,
$formname, $type, $size, $error, $this->lang, $this->_chmod);
but the constructor marks missing size instantly as NO_USER_FILE:
if (empty($name) || $size == 0) {
$error = 'NO_USER_FILE';
} elseif ($tmp == 'none') {
$error = 'TOO_LARGE';
here i also provide suggested code fix for the missing constant:
// map error codes from 4.2.0 $_FILES['userfile']['error']
if (function_exists('version_compare') &&
version_compare(phpversion(), '4.2.0', 'ge')) {
$uploadError = array(
1 => 'TOO_LARGE',
2 => 'TOO_LARGE',
3 => 'PARTIAL',
4 => 'NO_USER_FILE'
);
if (version_compare(phpversion(), '4.3.10', 'ge')) {
$uploadError[6] = 'NO_TMP_DIR';
}
}
Expected result:
----------------
isError() should return TOO_LARGE not NO_USER_FILE error.
Actual result:
--------------
error from upload says: NO_USER_FILE
[2005-06-06 13:58 UTC] glen at delfi dot ee
here's the fix for the bug:
http://cvs.pld-linux.org/cgi-bin/cvsweb/SOURCES/php-pear-HTTP_Upload-bug-4441.patch