|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-13 11:18 UTC] tony2001@php.net
[2006-07-13 12:46 UTC] rene dot schernus at siemens dot com
[2006-07-13 12:54 UTC] tony2001@php.net
[2006-07-17 12:00 UTC] rene dot schernus at siemens dot com
[2006-07-22 12:15 UTC] sniper@php.net
[2006-07-30 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 16 14:00:01 2025 UTC |
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--