browser lang:en
Some hosts disabled the ini setting allow_url_fopen. This also means that the ability to easily grab images by calling imagecreatefromjpeg($img) where $img is a url for an external image does not work.
This is a shame as this technique is pretty easy..
$remote_img = 'http://www.somwhere.com/images/image.jpg'; $img = imagecreatefromjpeg($remote_img); $path = 'images/'; imagejpeg($img, $path);
However I was goin crazy trying to get a product feed integration system to work on a host that has disabled the allow_url_fopen mechanism which meant the above wouldnt work.
Thankfully cURL was still working. So here is the function I made for grabbing and saving an image using cURL instead:
//Alternative Image Saving Using cURL seeing as allow_url_fopen is disabled - bummer
function save_image($img,$fullpath){
$ch = curl_init ($img);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec($ch);
curl_close ($ch);
if(file_exists($fullpath)){
unlink($fullpath);
}
$fp = fopen($fullpath,'x');
fwrite($fp, $rawdata);
fclose($fp);
}
Have you ever had to develop something yourself only to find out that there had already been…
in:JQuery (0 comments)The situation begins with your blog or website and you need to post some code on a particular…
in:The Holy Faq's (0 comments)So. Google just recently announced Google Buzz. I’m not sure about you, but I…
in:Blog (0 comments)There's lots of clever scripts around to tell you how to get images in and out of…
in:PHP scripts (0 comments)Spherical Law of Cosines Suppose that we want to find the five nearest places to (47.470779, -87.890699) using Spherical…
in:MySql (0 comments)I have always used Dreamweaver, and love it. But, I have been thinking, what are the FREE CSS…
in:Free Software (0 comments)Advanced Linux Sound Architecture (known by the acronym ALSA) is a Linux kernel component intended to replace the…
in:Blog (0 comments)The Singleton Pattern is one of the GoF (Gang of Four) Patterns. This particular pattern provides a…
in:Scripts and tutorials (0 comments)
