ID: 49611 User updated by: d dot reade at readesresidential dot com Reported By: d dot reade at readesresidential dot com Status: Bogus Bug Type: Filesystem function related Operating System: CentOS 5.3 x86 PHP Version: 5.2.11 New Comment:
That works fine, but it's a single file. The script I'm running is fetching up to 80 images from a remote source (based on the same network) and compiling into a PDF. I rebooted the server a few minutes ago and tried again... The script completed no problem, fetched all images and compiled into a PDF. So I tried again, but it failed half way through. The reason it gave was imagecreatefrompng complaining one of the PNG files was corrupt. I checked the PNG file and it contained the header information: HTTP/1.1 200 OK Date: Sun, 20 Sep 2009 22:03:29 GMT Server: Apache Last-Modified: Tue, 15 Sep 2009 14:04:55 GMT Accept-Ranges: bytes Content-Length: 883 Cache-Control: max-age=2592000 Expires: Tue, 20 Oct 2009 22:03:29 GMT Connection: close Content-Type: image/png �PNG There were other files in the same folder (the /tmp folder) that were created as part of the same job, which compiled into temporary PNGs and JPEGs no problem, with no header information. This has only started happening since PHP 5.2.11. I thought this was a bug since if I recompile Apache with PHP 5.2.10 instead leaving the configuration in tact, and try again, the script completes, again and again no problem. It never fails. Is there any reason why PHP is adding header info to files instead of just the file contents? Previous Comments: ------------------------------------------------------------------------ [2009-09-20 21:04:58] ras...@php.net And you can reproduce it with a 2-liner like that? I can't on my Linux box. Try this on your system: $img = file_get_contents('http://slowgeek.com/flat.png'); file_put_contents('flat.png',$img); run it a couple of times from the command line. Is your flat.png ever corrupted? ------------------------------------------------------------------------ [2009-09-20 20:54:47] d dot reade at readesresidential dot com Ah fair play, sorry for the confusion. It was an example of what functions I was using. The real code uses http:// to fetch the required image. ------------------------------------------------------------------------ [2009-09-20 20:50:53] ras...@php.net The thing that doesn't make sense in your bug report is that your reproduce code just says: $file = file_get_contents('image.jpg'); file_put_contents('newimage.jpg', $file); There is no HTTP involved here, so where would the HTTP headers come from? ------------------------------------------------------------------------ [2009-09-20 20:28:08] d dot reade at readesresidential dot com But the problem stops occurring as soon as I downgrade to PHP 5.2.10. No changes are being made to any configuration or extensions either. ------------------------------------------------------------------------ [2009-09-20 19:55:17] paj...@php.net Can't reproduce on many servers/platforms. Double check your script or config, something could be wrong. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/49611 -- Edit this bug report at http://bugs.php.net/?id=49611&edit=1