Reputation: 3554
<?php
//Get the file
$content = 'http://dev.aviesta.com.mx/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/b/r/bridal-shoes1.jpg ';
//Store in the filesystem.
$fp = fopen('/var/www/ajaxForm/loading.gif', 'w');
fwrite($fp, $content);
fclose($fp);
?>
I am getting following error when i try this
Warning: fopen(/var/www/ajaxForm/loading.gif): failed to open stream: No such file or directory in /var/www/curlimage.php on line 5 Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/curlimage.php on line 6 Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/curlimage.php on line 7
Upvotes: 2
Views: 9526
Reputation: 54072
Just taken from similar question
$url = 'http://dev.aviesta.com.mx/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/b/r/bridal-shoes1.jpg';
$img = 'curl/curl_image.jpg';
file_put_contents($img, file_get_contents($url));
Note : also check the directory is writable with is_writable method
References :
Upvotes: 6
Reputation: 2905
Do you need to save that image? I don't know why you write this code, you can't open a gif image and write another into it. If you want to save that image then you can use
file_put_contents("imgfolder/imgID.jpg", $image);
or copy($image_url, $your_path);
Upvotes: 3