I have a problem with PHP curl library.
At this URL: http://i.ebayimg.com/00/s/NTAwWDUwMA==/z/7KcAAOxyRhBS3lhE/$_1.JPG?set_id=8800005007
there's an image. For "curl", image does not exist.
I'm very confused. Following my method:
public static function downloadImage($url, $pathToSave = "")
{
$imageUrl = (string)$url;
$ch = curl_init($imageUrl);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$raw = curl_exec($ch);
curl_close($ch);
if(file_exists($pathToSave))
{
unlink($pathToSave);
}
$fp = fopen($pathToSave, 'x');
fwrite($fp, $raw);
fclose($fp);
return $pathToSave;
}