Top Menu

How can save images without use of browser with the help of Curl.
Some time we need save url image help of code without open browser
This function save image without open link.
$url=”http://google.com/imagename.jpg”;                                                                          
$ch = curl_init($url);
$fp = fopen(‘folderpath/card1.jpg’, ‘wb’);// folder path where you save image
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
Note : One of the main reasons to use cURL to save or display a remote image is that some servers/hosts have allow_url_fopen turned off. This means functions like fopencan’t open files held on external servers.
I hope you have enjoyed this tutorial

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Close