php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42280 Change in file upload behavior
Submitted: 2007-08-12 21:30 UTC Modified: 2007-08-14 23:21 UTC
From: chris at dented-planet dot net Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.4RC1 OS: Mac OS X 10.4.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chris at dented-planet dot net
New email:
PHP Version: OS:

 

 [2007-08-12 21:30 UTC] chris at dented-planet dot net
Description:
------------
I don't know if this is considered a bug there there has been a change in behavior in the File Upload handling when uploading a zero-length file.

The change happened after PHP 5.2.2 and is in 5.2.4RC1 as well.

Note: I am not using a debug build.


Reproduce code:
---------------
Use this code to upload a zero-length file (I used Firefox 1.5.x):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head></head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>" enctype="multipart/form-data">
<input type="file" name="upload_file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<br />
<pre>
<?php
var_dump($_FILES);
?>
</pre>
</body>
</html>


Expected result:
----------------
In PHP 5.2.2, the output of var_dump($_FILES) is:

array(1) {
  ["upload_file"]=>
  array(5) {
    ["name"]=>
    string(9) "empty.txt"
    ["type"]=>
    string(10) "text/plain"
    ["tmp_name"]=>
    string(18) "/var/tmp/phpLAvnSB"
    ["error"]=>
    int(0)
    ["size"]=>
    int(0)
  }
}

In PHP 5.2.3 and later it is:

array(1) {
  ["upload_file"]=>
  array(5) {
    ["name"]=>
    string(9) "empty.txt"
    ["type"]=>
    string(0) ""
    ["tmp_name"]=>
    string(0) ""
    ["error"]=>
    int(5)
    ["size"]=>
    int(0)
  }
}

Especially, notice the change in "error".


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-12 22:16 UTC] jani@php.net
Are you absolutely sure you do NOT have a debug build? (check from phpinfo() output..) I can't see any way in sources for the error to be '5' if you really aren't using a debug build. It's only possible if you have patched the sources..
 [2007-08-12 22:45 UTC] chris at dented-planet dot net
I compiled each version myself from source downloaded from php.net

I used the --disable-debug config setting and phpinfo() says "Debug Build No"
 [2007-08-14 23:21 UTC] chris at dented-planet dot net
There is no bug here. Only someone who doesn't completely understand how to compile source code.

I was reusing the same source download over and over switching between --enable-debug and --disable-debug. While I rm'd config.cache, I didn't remove other generated files in the source directory. I assumed they'd be overwritten.

Once I downloaded a virgin source code for 5.2.3, the "bug" no longer occurred.

Sorry!

That being said, can you suggest a good book on learning and compiling C? I think it's about time I learn a bit more so this doesn't happen again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 07:01:34 2024 UTC