#38092 [Fbk->Opn]: Upload of Image damages the image
| From: | rene dot schernus at siemens dot com | Date: | Thu, 13 Jul 2006 12:46:37 +0000 |
| Subject: | #38092 [Fbk->Opn]: Upload of Image damages the image | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99402@lists.php.net to get a copy of this message | ||
ID: 38092
User updated by: rene dot schernus at siemens dot com
Reported By: rene dot schernus at siemens dot com
-Status: Feedback
+Status: Open
Bug Type: Unknown/Other Function
Operating System: RedHat ES30
PHP Version: 4.4.2
New Comment:
Apache Webserver 2.0.46, Server API Apache 2.0 Filter.
Yes i tried on a different host. Redhat ES40, Apache 2.0.55, Server API
Apache 2.0 Handler and it works fine.
thx
Previous Comments:
------------------------------------------------------------------------
[2006-07-13 11:18:28] tony2001@php.net
Which web-server is that? Which PHP SAPI is used? Did you try it on a
different host/OS/webserver?
Definitely not reproducible here.
------------------------------------------------------------------------
[2006-07-13 11:03:45] rene dot schernus at siemens dot com
Description:
------------
If i upload an jpg-file and save the stream to disk my jpg is damaged
after this. If i view the "source" of the jpg i can see that the
html-form data is appended. "Content-Disposition: form-data;
name="userpic"; filename="66_automotive_102x72_1305008.jpg"
Content-Type: image/jpeg". The size of the file i doubled.
If i set an directive in the apache config like
"ForceType image/jpg" and upload again the jpg isn´t damaged.
Reproduce code:
---------------
Upload Source:
<?php
$original = $_FILES['userpic']['tmp_name'];
$filename = $_FILES['userpic']['name'];
if ($original != '') {
copy($_FILES["userpic"]["tmp_name"], "./tmp/".$filename);
$filename= "./tmp/".$filename;
print "<img src=".$filename.">";
$handle = fopen ($original, "rb");
$contents = fread ($handle, filesize ($original));
$len = strlen($contents);
$pos = strpos($contents, 'Type:');
#print "<BR>";
#print "<BR>";
print $contents."<BR>";
fclose ($handle);
exit;
}
?>
<FORM enctype="multipart/form-data" method="post">
<TABLE>
<TR><TD>
<INPUT type='file' name='userpic' /><input name='weilhalt'
type='hidden' value='wert'><INPUT type='hidden'
name='target_input'
value="seite_teaser" /></TD>
<TD align='right'><INPUT type='submit' name='confirm'
class='button'
value='hochladen' /><BR></TD></TR>
</TABLE>
</form>
Expected result:
----------------
A normal upload.
Actual result:
--------------
Source of uploaded jpg:
--snip--
^@^@^@H^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@8BIM^D^Q^@^@^@^@^@^A^A^@8BIM^D^T^@^@^@^@^@-----------------------------7301164174495^M
Content-Disposition: form-data; name="userpic";
filename="66_automotive_102x72_1305008.jpg"^M
Content-Type: image/jpeg^M
^M
ÿÃÿà ^@^PJFIF^@^A^B^A^@·^@·^@^@ÿÃ^N¦Photoshop
3.0^@8BIM^CÃ^@^@^@^@^@^P^@¶áH^@^B^@^B^@¶áH^@^B^@^B8BIM^D^M^@^@^@^@IM^D^Y^@^@^@^@^@^D^@^@^@^^8BIM^Có^@^@^@^@^@
^@^@^@^@^@^@^@^@^A^@8BIM^D
^@^@^@^@^@^A^@^@8BIM'^P^@^@^@^@^@
--snip--
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38092&edit=1