header('Content-type: image/jpeg');
$context=array('http' => array ('header'=> 'Referer: http://www.baidu.com/',),);
$xcontext = stream_context_create($context);
echo $str=file_get_contents($url,FALSE,$xcontext);
主要是针对Referer验证防护的盗链解决办法,在前端对加载的图片url进行改写,执行此脚本作为中转。