Php download image from url

Easy way to download and save a remote image on your own server, using php.


$image = file_get_contents('http://www.url.com/image.jpg');
file_put_contents('/images/image.jpg', $image); //Where to save the image on your server

You may use function like this

function download_image ($location, $url)
{
   $content = file_get_contents($url);
   if ($content){
   $fp = fopen($location, "w");
   fwrite($fp, $content);
   fclose($fp);
    }
   return $content;
}
(Visited 7 times, 1 visits today)

Comments

comments

Leave a Reply