Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0b4

Bug #10769 Err: NO_USER_FILE instead of TOO_LARGE
Submitted: 2007-04-18 15:18 UTC
From: darizotas Assigned: cweiske
Status: Closed Package: HTTP_Upload (version 0.9.1)
PHP Version: 5.2.1 OS: Windows XP SP2
Roadmaps: (Not assigned)    
Subscription  


 [2007-04-18 15:18 UTC] darizotas (Dario Borreguero)
Description: ------------ Whenever I upload a file with size exceeds allowed I get the error: NO_USER_FILE instead of TOO_LARGE. After debugging Upload.php code I found that on line 302 (HTTP_Upload constructor) that $_FILES is empty. The issue is that, as it is said in the comment added by "v3 (&) sonic-world.ru" at http://es2.php.net/features.file-upload, if the POST size exceeds the server limit, both $_POST and $_FILES will be empty. Therefore, POST size should be checked, just to avoid NO_USER_FILE error get on function "_buildFiles" line 393. I hope this helps, Dario. Expected result: ---------------- error TOO_LARGE Actual result: -------------- error NO_USER_FILE

Comments

 [2007-06-15 12:57 UTC] darizotas (Dario Borreguero)
I have checked again the code and I have found the following: 1. function HTTP_Upload::_buildFiles() The comment says $_FILES should only be checked if php version is between the releases 4.1 and 4.3. But the code just compares that the php version is greater than 4.1. [388] // In 4.1 $_FILES isn't initialized when no uploads [389] // XXX (cox) afaik, in >= 4.1 and <= 4.3 only [390] if (function_exists('version_compare') && [391] version_compare(phpversion(), '4.1', 'ge')) [392] { So I just changed the code: [388] // In 4.1 $_FILES isn't initialized when no uploads [389] // XXX (cox) afaik, in >= 4.1 and <= 4.3 only [390] if (function_exists('version_compare') && [391] version_compare(phpversion(), '4.1', 'ge') && [392] version_compare(phpversion(), '4.3', 'le')) [393] { 2. function HTTP_Upload_File::HTTP_Upload_File() The constructor checks whether the $name or $size are empty. Whenever I upload a file that exceeds the maximum, the $name is given, but the $size is 0. Therefore, the error message is always NO_USER_FILE. [564] if (empty($name) || $size == 0) { I've modified the condition to: [564] if (empty($name) && $size == 0) { After these changes, it seems to work properly. But I am not pretty sure whether they are correct or not. Regards, Dario.
 [2008-01-21 01:15 UTC] honeyatelier (Zhou Beichen)
I do like this: [564] if (empty($name) || $size == 0) { modified to: [564] if (empty($name) && $size == 0) { well done!
 [2009-08-16 14:44 UTC] cweiske (Christian Weiske)
-Type: Feature/Change Request +Type: Bug
 [2009-08-16 19:00 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Verified
I can confirm this. The problem happens when the filesize is larger than post_max_size and upload_max_filesize as defined in php.ini - not when the user-defined post form field is exceeded.
 [2009-08-16 19:08 UTC] cweiske (Christian Weiske)
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cweiske
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I had to solve it in a different way.