php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9899 POST Upload corrupted with Content-type string
Submitted: 2001-03-21 09:32 UTC Modified: 2002-06-16 08:20 UTC
From: tkircht at ipodion dot at Assigned:
Status: Not a bug Package: Misbehaving function
PHP Version: 3.0.17 OS: RedHat/Linux 2.2.16-22
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:
MUST BE VALID
Solve the problem:
45 + 15 = ?
Subscribe to this entry?

 
 [2001-03-21 09:32 UTC] tkircht at ipodion dot at
I am using PHP 3.0.18-1.6 on a RedHat system.I am using the following script to upload files to the server:

[...]
<FORM ENCTYPE="multipart/form-data" ACTION="process.php3" METHOD=POST>
 <TABLE WIDTH="75%" BORDER="0">
    <TR>
      <TD>
        <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="5000000">
        Name: </TD>
       <TD>
        <INPUT TYPE="Text" NAME=username SIZE="50">
      </TD>
    </TR>
 <TR>
[...] 

==============================================
And this for copying the file to the harddisk:
==============================================
  <TD>
        <INPUT NAME="userfile" TYPE="file" SIZE="50">
      </TD><?
printf ("Name: %s <br>\n",$username);
printf ("FileName: %s <br>\n",$userfile_name);
printf ("FileSize: %s Bytes<br>\n",$userfile_size);
printf ("FileType: %s <br>\n",$userfile_type);
 
if ( $userfile_size == 0 )
{
printf ("<p><strong>Achtung! Datei ist gr&ouml;&szlig;er als 5MB - Upload verweigert</strong></p>");
};
 
$category=trim($category);
$username=trim($username);
 
printf ("TmpFileName: %s <br>\n",$userfile);
printf ("Category: %s <br>\n",$category);
$ext=substr($userfile_name,-3,3);
$newfilename=sprintf("%s/%s.%s",$category,$username,$ext);
if ( ! file_exists($category)){
   umask(0);
   mkdir($category,04770);
  }
if (copy($userfile,$newfilename))
        {
        chmod($newfilename,0775);
        printf("<p><strong>%s wurde erfolgreich empfangen und als <a href=%s>%s</a> abgelegt!</strong></p>",$userfile_name,$category,$newfilename);
        }
        else
        {
        printf("<p><strong>%s konnte nicht als %s-%s abgelegt werden</strong></p>",$userfile_name,$category,$newfilename);
        };
?>
 </TR>
</TABLE>
  <br>
  <INPUT TYPE="submit" VALUE="Abschicken">
</FORM>

The resulting files contain

[root@coimbra Studenten]# head -2 Technische_Physik/me.wav
Content-Type: audio/wav
 
[root@coimbra Studenten]#

as the first two lines, making them unusable for binary types.

the $userfile_type variable is empty.

This used to work fine with PHP 3.0.14.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-16 08:20 UTC] sander@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately, PHP 3 is no longer supported. Please download
the latest version of PHP 4 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: Sat Apr 20 06:01:28 2024 UTC