I need to save an image from a PHP URL to my PC.
Let\'s say I have a page, http://example.com/image.php
, holding a single \"flower\" image, nothing else. How ca
Vartec's answer with cURL didn't work for me. It did, with a slight improvement due to my specific problem.
e.g.,
When there is a redirect on the server (like when you are trying to save the facebook profile image) you will need following option set:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
The full solution becomes:
$ch = curl_init('http://example.com/image.php');
$fp = fopen('/my/folder/flower.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);