Friday, 27 May 2016

Download image from url and save on my server using PHP


Download image from url and save on my server using php

Kindly Use below code to download image and store it to your own server.

//Get the file
$url = "http://ranachandresh.blogspot.in/chandresh.jpg";  //test url you can use your own url
$content = file_get_contents($url);

//Store in media.
$imageInfo = pathinfo($url);
$imageName = $imageInfo['basename'];
$fp = fopen("../media/import/".$imageName, "w");  // You can use your own path here
fwrite($fp, $content);
fclose($fp);


That's it. Enjoy Chandresh rana Coding...

No comments: