#49611 [Bgs]: file_get_contents automatically including headers in output

From: Date: Sun, 20 Sep 2009 21:04:58 +0000
Subject: #49611 [Bgs]: file_get_contents automatically including headers in output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-142616@lists.php.net to get a copy of this message
ID: 49611 Updated by: rasmus@php.net 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: 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? Previous Comments: ------------------------------------------------------------------------ [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] rasmus@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] pajoye@php.net Can't reproduce on many servers/platforms. Double check your script or config, something could be wrong. ------------------------------------------------------------------------ [2009-09-20 18:04:39] d dot reade at readesresidential dot com Just to clarify the header information is being automatically added to random images (not all) since PHP 5.2.11. I have seen a similar bug report, however my issue has occurred since installing PHP 5.2.11 today. Downgrading to PHP 5.2.10 fixes the problem and everything works as expected from that point on. ------------------------------------------------------------------------ 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

« previous php.bugs (#142616) next »