From: publicfreedom at yahoo dot com Operating system: RedHat Linux PHP version: 4.3.4 PHP Bug Type: Filesystem function related Bug description: fopen , fread or fwrite bug
Description: ------------ Hello, I have a php program that reads a file from a given URL and then recreates it on my server host using fopen, fread and fwrite. The program was running perfectly with php version 4.2.3 for the last 9 months, then when my hosting provider upgraded to php version 4.3.4 it produced the following bug: When the file URL is recreated it is sometimes not complete, i.e the number of bytes of the new recreated file is less than the original file which results in an incompleted or corrupted file. I reported my hosting provider with the bug, but they told me to contact php.net . Is there a fix for that? Please help. Here is a link to the part of the program that is not working. I have illustrated it clearly. http://ssviewpoint.com/filetest/index.php Thank you. Reproduce code: --------------- <? $fileurl ='http://www.google.com/intl/en_ALL/images/images_hp.gif'; $fd =fopen ($fileurl,"rb"); if (!$fd){ echo "<p><br>Unable to open remote file.<br> Name : <b>$fileurl<b>"; exit; } //if $fd $fs=8388608; //1Mb = 1048576 - now fs is 80 Mb $contents =fread ($fd,$fs); fclose ($fd); //Now the binary contents of file is in $contents $newfilename= 'googlefile.gif'; $fdffp =fopen($newfilename,"w"); fwrite($fdffp,$contents); fclose($fdffp); $thesize= filesize($newfilename); //$newfilename should be an identical copy of $fileurl and $thesize should be its size but it is not. ?> Expected result: ---------------- I expect to find an identical file of the file in the given URL, created on my host. Actual result: -------------- The new created file is less in size than the actual size which results in a corrupted file. -- Edit bug report at http://bugs.php.net/?id=27851&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27851&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27851&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27851&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27851&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27851&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27851&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27851&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27851&r=support Expected behavior: http://bugs.php.net/fix.php?id=27851&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27851&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27851&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27851&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27851&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27851&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27851&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27851&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27851&r=float