I am using cURL to retrieve an image, rename it and store it locally. The images comes up as 0 byte file, no matter, whether I use cURL, like so:
$strImageUrl = curl_init($strImageUrlSource);
$fp = fopen($strTargetImage, 'wb');
curl_setopt($strImageUrl, CURLOPT_FILE, $fp);
curl_setopt($strImageUrl, CURLOPT_HEADER, 0);
curl_exec($strImageUrl);
curl_close($strImageUrl);
fclose($fp);
or file_put/get. like so:
file_put_contents($strImageName, file_get_contents($strImageUrlSource));
The URL I am retrieving is:
<img src='http://i1.au.reastatic.net/150x112/73fa6c02a92d60a76320d0e89dfbc1a36a6e46c818f74772dec65bae6959c62f/main.jpg' width="150" height="112" alt="Wondecla, address available on request" title="Wondecla, address available on request" />
I can save this image properly manually. When looking at the properties in FireFox it shows three entries:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABYBAMAAACDuy0HAAAAG1BMVEX+/v4BAQH///8KCgoDAwN/f3/19fWAgID8... etc
data:image/png;base64,iVBORw0KG ... etc.
What am I doing wrong here?