http://7xigfd.com1.z0.glb.clouddn.com/wp-content/uploads/2015/08/134.jpg
function image($url, $referer_url) {
//$url = $this->input->get('url');
$dir = pathinfo($url);
$host = $dir['dirname'];
$refer = $host . '/';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_REFERER, $refer);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $referer_url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); //模拟用户使用的浏览器
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); //在发起连接前等待的时间,如果设置为0,则无限等待
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //设置超时限制防止死循环
$data = curl_exec($ch);
curl_close($ch);
$ext = strtolower(substr(strrchr($url, '.'), 1, 10));
$types = array(
'gif' => 'image/gif',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'jpe' => 'image/jpeg',
'png' => 'image/png',
);
$type = $types[$ext] ? $types[$ext] : 'image/jpeg';
header("Content-type: " . $type);
echo $data;
}这种方法不行 有没有可用的方法?
echo "";
这样不行吗?
echo "";
这样不行吗?
总不能无中生有吧?
总不能无中生有吧?
总不能无中生有吧?
图片不存在或没有权限访问。
图片不存在或没有权限访问。