Re: Remote grabbed images are blank
| From: | Rick Fletcher | Date: | Tue, 12 Oct 2004 20:22:43 +0000 |
| Subject: | Re: Remote grabbed images are blank | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199294@lists.php.net to get a copy of this message | ||
Mag wrote:
Hi, I got a pretty good code snippet from Zend to grap a remote image and save it to disk, the problem is, when it saves to my disk i am unable to open the images...they are blank and the file matches the remote images filesize...[snip]
ob_start(); readfile($url); $img = ob_get_contents(); ob_end_clean(); $size = strlen($img); $fp2=@fopen($filename, "a"); fwrite($fp2,$img); fclose($fp2);I'm not sure what the problem is, but simplifying the code will help you track it down. Rather than messing with output buffering and fopen/fwrite/fclose, I'd suggest using the copy() function. This line replaces the 8 lines above: copy( $url, $filename ); --Rick