ID:               27069
 Updated by:       [EMAIL PROTECTED]
 Reported By:      franz at ess dot co dot at
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Red Hat 9.0
 PHP Version:      4.3.4
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Works fine for me with the latest CVS.



Previous Comments:
------------------------------------------------------------------------

[2004-01-28 06:10:57] franz at ess dot co dot at

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.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=27069&edit=1

Reply via email to