php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15526 Uploading of binary file
Submitted: 2002-02-12 12:58 UTC Modified: 2002-06-15 09:49 UTC
From: jsebestik at seznam dot cz Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.1.1 OS: linux
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: jsebestik at seznam dot cz
New email:
PHP Version: OS:

 

 [2002-02-12 12:58 UTC] jsebestik at seznam dot cz
//When some binary data are send to this script it cause netscape //unstable because PHP engine read STDIN incorrectly.
//I have try to read this data with script in perl an it was successful.
//I append apache logs that this incorrect reading of input causes.
//x.y.x.z - - [12/Feb/2002:17:28:31 +0100] "POST   /IR/Edit/index.php //HTTP/1.0" 200 431 "/IR/Edit/index.php" "Mozilla/4.77 [en] (X11;  U; //Linux 2.4.2-2 i686)" 
//x.y.x.z - - [12/Feb/2002:17:28:31 +0100] "<9D>?Y??+k?<9C><9A>YŦ|]z/?;?
//<85>????$?#]?gbu\??e??<87>^B" 200 5364 "-" "-"
//first log is ok
//but second is proof of this uncorrect STDIN reading
//it not depend if function 

//move_uploaded_file($HTTP_POST_FILES['userfile'],"/place/to/put/uploaded///file");
//or
//copy($HTTP_POST_FILES['userfile']['tmp_name'],"/place/to/put/uploaded/////file");
//are used.

//This error don't occure if I try to upload file of text/plain.
//But have been occuring ever when I try to read i.e. image/gif

<TABLE bgcolor=#ffffff>
<FORM ENCTYPE="multipart/form-data" METHOD=POST ACTION="<?PHP 
 echo "http://$SERVER_NAME$SCRIPT_NAME"; 
//   echo "http://$SERVER_NAME/cgi-bin/UpLoader";
?>">
<TR><TD></TD><TD></TD></TR>
<TR><TD>Sample name:</TD><TD><INPUT NAME="Sample" TYPE=TEXT></TD></TR>
<TR><TD valign=top>Notes:</TD><TD><TEXTAREA NAME="SpNotes" ROWS=5 COLS=50></TEXT
AREA></TD></TR>
 <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">
<TR><TD>Send this file: </TD><TD><INPUT NAME="userfile" TYPE="file"></TD></TR>
<TR><TD><INPUT TYPE="submit" VALUE="Send File"></TD><TD><INPUT TYPE="reset"></TD
></TR>
 </FORM>
</TABLE>
<?PHP
 $Sample = preg_replace("/[^a-zA-Z0-9]/","",$Sample);
 if ($Sample != "")
  {
if (move_uploaded_file($HTTP_POST_FILES['userfile'], $IRDirectory . $Sample 
. ".ir" ))
     {
     
         if ($SpNotes != "")
          {
           $fp = fopen($IRDirectory . $Sample . ".txt","w+");
           fwrite($fp, $SpNotes);
           fclose($fp);
          } 
       }
    else
     {
       echo "File not found !!!\n";

     }
  }

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-03 02:52 UTC] yohgaki@php.net
Could you try 4.2.0RC1?
Please visit http://qa.php.net/ for 4.2.0RC1.

 [2002-05-06 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-05-09 13:16 UTC] jsebestik at seznam dot cz
Well, I have two messages. First is a well one and second is a bit but. I try php-4.2.1RC2. It reads STDIN correctly. It means that no corrupted logs appear. But function move_uploaded_file doesn't work properly. On the other hand
it could be substitued with these one or two lines:
$fltmp = $HTTP_POST_FILES['userfile']['tmp_name'];
 if (file_exists($fltmp))
     {
        rename($fltmp, $IRDirectory . $Sample . ".ir" ); 
     }
Such substitution works very well.
 [2002-06-15 09:49 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 12:01:31 2024 UTC