As mentioned above, the php file_get_contents () function or even the fopen () / fread () combination flock and the wait time when trying to read this simple image URL:
http://pics.redblue.de/artikelid/GR/1140436/fee_786_587_png
but the same image is easily downloaded by browsers, what is the catch?
Edition:
as pointed out in the comments, I show the function that I used to get the data:
function customRead($url) { $contents = ''; $handle = fopen($url, "rb"); $dex = 0; while ( !feof($handle) ) { if ( $dex++ > 100 ) break; $contents .= fread($handle, 2048); } fclose($handle); echo "\nbreaking due to too many calls...\n"; return $contents; }
I also tried simply:
echo file_get_contents('http://pics.redblue.de/artikelid/GR/1140436/fee_786_587_png');
Both give the same problem
Edition:
As suggested in the comment, I used curl:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.1 Safari/537.11'); $res = curl_exec($ch); $rescode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch) ; echo "\n\n\n[DATA:"; echo $res; echo "]\n\n\n[CODE:"; print_r($rescode); echo "]\n\n\n[ERROR:"; echo curl_error($ch); echo "]\n\n\n";
this is the result:
[DATA:] [CODE:0] [ERROR:]