Reputation: 41
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 some 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?
Upvotes: 2
Views: 5399
Reputation: 7656
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.
Upvotes: 4
Reputation: 20343
Or rather just save the image to your own website. Hotlinking images from different sites is generally considered bandwidth stealing by the netiquette.
Upvotes: 0