php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30093 Error with file upload
Submitted: 2004-09-15 15:58 UTC Modified: 2004-09-29 15:53 UTC
From: marcus dot stolzenberg at kgrz-kassel dot de Assigned: jorton (profile)
Status: Closed Package: HTTP related
PHP Version: 4.3.9RC3 OS: SLES 8.0 zSeries s390 IBM
Private report: No CVE-ID: None
 [2004-09-15 15:58 UTC] marcus dot stolzenberg at kgrz-kassel dot de
Description:
------------
Hello,

First the 'error' is also in 4.3.9rc1 with 4.3.6 everything is fine.

If I am going to upload a file using php which is not txt encoded the file size of the transfered file is more then doubble and the file stored on the server is corrupted.

Reproduce code:
---------------
1. HTML Part:

<form enctype="multipart/form-data" action="upload.php" method="post"> 
<input type="file" name="file"><br> 
<input type="submit" value="upload"> 
</form>

2. PHP Part:

$tempname = $_FILES['file']['tmp_name'];
$name = $_FILES['file']['name']; 
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];
...
print_r($_FILES);
echo $size;
   copy("$tempname", "/upload/$name");
    
...


Expected result:
----------------
Output useing 4.3.6

Array ( [file] => Array ( [name] => daemon347.exe [type] => application/octet-stream [tmp_name] => /uploadkds/phpJGle3P [error] => 0 [size] => 504320 ) ) Array ( ) 

504320



504320 = filesize of desination file on the server = original file size


Actual result:
--------------
Output 4.3.9rc1 and 4.3.9rc3


Array ( [file] => Array ( [name] => daemon347.exe [type] => application/octet-stream [tmp_name] => /uploadkds/phplvCHls [error] => 0 [size] => 1004032 ) ) Array ( ) 

1004032 



1004032 = filesize of desination file on the server =! original size


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-16 05:36 UTC] rasmus@php.net
I just updated one of my servers to PHP_4_3 HEAD and large image file uploads are working fine both single and multiple at a time.

Are we really talking about an S390 here?
 [2004-09-16 09:41 UTC] marcus dot stolzenberg at kgrz-kassel dot de
Hi,

Yes I have some linux partitions on our IBM mainframe with php... We are running Suse Linux Enterprice Server 8.0 on 31 bit zSeries s390 / zOS

I send a make test with 4.3.9rc3 yesterday to: php-qa@lists.php.net maybee it helps.

I think I will try the HEAD version this evening and than I will report...

Marcus
 [2004-09-17 12:27 UTC] marcus dot stolzenberg at kgrz-kassel dot de
Hi,

I did the test with the: PHP Version 4.3.9RC4-dev / STABLE-200409161030


Same problem:

Array ( [file] => Array ( [name] => daemon347.exe [type] => application/octet-stream [tmp_name] => /uploadkds/phpg9gWFe [error] => 0 [size] => 1004032 ) ) Array ( ) 

1004032

Marcus
 [2004-09-28 23:05 UTC] sniper@php.net
Have you tried PHP 4.3.8 ? Or 4.3.7 ? (would help us to know when this bug appeared first time)

 [2004-09-29 12:13 UTC] marcus dot stolzenberg at kgrz-kassel dot de
Hi,

I' m really sorry... but I was wrong!
I did some test the last days with different php versions (4.3.6 - 4.3.9). I found out that the problem is not the php release. The problem is using Apache 2.0.50 together with any (4.3.6 - 4.3.9) PHP release. Using Apache/2.0.46 every version of PHP works fine...

Outout with 4.3.9:
Array ( [file] => Array ( [name] => Test.exe [type] => application/octet-stream [tmp_name] => /uploadkds/phpAZU372 [error] => 0 [size] => 1999592 ) ) Array ( ) 

1999592 = original file size :))

But now I did not know is the problem "in" apache or in php running together with apache 2.0.50...

Is there a possibility to find this out so that I have to post the "bug" to apache group?


Thanks,
Marcus
 [2004-09-29 14:55 UTC] derick@php.net
Joe, do you have any idea about this? I'd say it's just an Apache problem...
 [2004-09-29 15:11 UTC] jorton@php.net
Screwups in POST body handling can happen if you use the apache2filter SAPI and you have it configured badly.  Things to try:

1) switch to apache2handler

2) remove any "SetInputFilter PHP" statements from your apache configuration, if you also have "AddType application/x-httpd-php .php".  The AddType is sufficient for the apache2filter to work correctly.  If you have both, it screws up.

2.0.51 + 4.3.9 (apache2handler) work fine on an s390x box here. (running RHEL not SLES)
 [2004-09-29 15:53 UTC] marcus dot stolzenberg at kgrz-kassel dot de
Hello,


Thank U for your answer now everything is fine....


Sorry so long!

Marcus
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Nov 17 00:01:34 2019 UTC