|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45124 $_FILES['upload']['size'] sometimes return zero and sometimes the filesize
Submitted: 2008-05-29 09:11 UTC Modified: 2008-09-07 18:02 UTC
Avg. Score:4.0 ± 0.9
Reproduced:4 of 5 (80.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: klas dot wirholm at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 5.2.6 OS: Arch Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
19 + 23 = ?
Subscribe to this entry?

 [2008-05-29 09:11 UTC] klas dot wirholm at gmail dot com
Sometimes when the uploaded file is bigger then MAX_FILE_SIZE (in script)the return from $_FILES['uploadedfile']['size'] is zero and sometimes it returns the right value of the file.

I have only tried whith MAX_FILE_SIZE far under what I have set in php.ini(upload_max_filesize = 2M).

Looks like it depends on how much bigger the file is then MAX_FILE_SIZE. Cant figure out the exact difference.

(the script I post is also my temporary solution for the problem)

Reproduce code:
define('MAX_FILE_SIZE', 1048);
elseif ($_FILES['uploadedfile']['size'] > MAX_FILE_SIZE or $_FILES['uploadedfile']['size'] <= 0) {
	$filesize = number_format($_FILES['uploadedfile']['size']/1024, 1).'KB';
	$uploadinfo = "<b>The image/file is proberly to bigg</b> (and maybee then returned zero)!<br /><br/ > We got this filesize from the upload file: " . $filesize ."<br /> Max acceptable size is " . $maxfs;

Expected result:
The exact filesize of the uploaded file (at least if its smaller then upload_max_filesize set in php.ini).

Actual result:
Sometimes the exact filesize of the uploaded file, sometimes zero.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-07 14:18 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Mar 31 03:03:40 2023 UTC