When opening an image (thru <img>
tag) using any of the major browsers the HTTP referer header is sent. I was trying setting src attribute to so开发者_如何学运维me https:// url (valid certificate, was hoping that going from secured to unsecured page will blank the referer) which then was redirecting to the target page (by Location header) and few other "methods", nothing seems to be working... any ideas please?
If I understand, this could do the trick:
$opts = array('http' =>
array(
'method' => 'GET',
'header' => 'Referer: http://example.com',
)
);
$context = stream_context_create($opts);
header('Content-Type: image/vnd.microsoft.icon');
echo file_get_contents($_GET['image_src'], false, $context);
And then in HTML:
<img src="/path/to/file.php?image_src=http://www.google.com/favicon.ico" alt="">
Hope it helps.
Or rather just save the image to your own website. Hotlinking images from different sites is generally considered bandwidth stealing by the netiquette.
精彩评论