stevesimo Posted August 15, 2008 Share Posted August 15, 2008 Hi, I have a php function which downloads an image in PNG format from a remote server and returns the result as a value called $content. Using the following code I can output the downloaded PNG image to the screen. header("Content-type: image"); print($content); My question is how can I store this PNG file on the server as an image file? Many thanks, Steve (Blackpool, UK) Link to comment https://forums.phpfreaks.com/topic/119799-solved-how-to-save-downloaded-image/ Share on other sites More sharing options...
ratcateme Posted August 15, 2008 Share Posted August 15, 2008 use fwrite and fopen() $image = fopen("image.png","w"); fwrite($image,$content); fclose($image); Scott. Link to comment https://forums.phpfreaks.com/topic/119799-solved-how-to-save-downloaded-image/#findComment-617182 Share on other sites More sharing options...
stevesimo Posted August 15, 2008 Author Share Posted August 15, 2008 Thanks for that, your code worked a treat! Link to comment https://forums.phpfreaks.com/topic/119799-solved-how-to-save-downloaded-image/#findComment-617183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.