|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-28 06:41 UTC] sniper@php.net
[2004-01-28 07:29 UTC] franz at ess dot co dot at
[2004-01-28 09:25 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 17:00:01 2025 UTC |
Description: ------------ I'm copying one binary file (currently GIF's) to another using fread on a file or URL opened for binary reading. The copy created is corrupted and doesn't has the same size as the source. The script runs nice under PHP-4.0.6 but fread seems to have an error in version PHP-4.3.4. Reproduce code: --------------- <?php // copies binary file "$from" to a file given by "$to" function CopyBin($from,$to) { if ($from) { $input = fopen($from, "rb"); $image_data = ""; $totlen=0; if($input) { $i=0; while(!feof($input)) { $inp = fread($input, 10000); $len = strlen($inp); $totlen+= $len; $i++; $image_data = $image_data . $inp; } } print ("Read in a Total of: $totlen\n"); fclose($input); $output = fopen("$to", "wb"); fwrite($output, $image_data); fclose($output); } } CopyBin("source.gif","copy.gif"); ?> Expected result: ---------------- A copy of the binary file source.gif should be in copy.gif Actual result: -------------- If I diff -a the 2 files it looks like a few "\0" are missing.