我试图通过 cURL 获取图像来显示图像,但没有显示任何内容。标头已正确发送,所以我接下来应该看哪里?
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
//$imgurl = $_GET['img'];
$query = curl_init();
$headers[] = 'Cache-Control: maxage=. $cache_expire';
$headers[] = 'Pragma: public';
$headers[] = 'Accept-Encoding: None';
//curl_setopt($query, CURLOPT_HTTPHEADER, $headers);
curl_setopt($query, CURLOPT_URL, "http://static4.fjcdn.com/comments/3885449+_bf7680ea243464ace7ddb3d912c7c7d6.jpg");
curl_setopt($query, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_HEADER, 1);
$ret = curl_exec($query);
if(!preg_match("/Content-Type\: image(.*)\r\n/i", $ret, $mime))
die("die potato!");
header($mime[0]);
echo substr(strstr($ret, "\r\n\r\n"), 4);
?>