View Single Post
Old 06-14-2005, 02:27 AM   #6 (permalink)
jaswinder_rana
The Acquainted
 
Join Date: May 2005
Posts: 106
Thanks: 0
jaswinder_rana is on a distinguished road
Default

Save image using file_get_contents

I am using talkphp logo for this example, hoping Ryan wouldn't mind :D

I din't know i could do this until i did. you can rad an image file and then save it. its like saving images automatically.
PHP Code:
$url 'http://www.talkphp.com/images/talkphp/logo2.gif'//MAKE SURE http is there

$contents = @file_get_contents($url);
if(!empty(
$contents))
{
 
$file $_SERVER['DOCUMENT_ROOT'].'/images/saved.gif';//Make sure images directory exists
 
$fh  = @fopen($file,'w');
 if(
$fh)
 {
   
fwrite($fh,$contents);
   
fclose($fh);
 }

and that would save file to your directory. Might not mean anything to you, but its good to know, coz i just used it today in my project. Ofcourse, legal rights should be taken care of.
__________________
---------------------------
Errors = Improved Programming.
Portfolio
Send a message via MSN to jaswinder_rana
jaswinder_rana is offline  
Reply With Quote