PHP Image Protection
-
Hiya everyone, So yes, as the title states, I'm trying to protect images on a website from being downloaded directly (privacy problems). What I've done (or am trying to do) is something like
<a href='img.php?file=blah.jpg'>
. However, in img.php, I don't know how to tell if the image is being requested in the actual page (index.html, lets say) with the<a>
tag, or if it's requested seperately by someone who's copied that url and viewed it (in a different window, maybe). I've tried$_SERVER['REQUEST_URI']
but that returnsimg.php?file=blah.jpg
under both circumstances. Is there any way I can find out? Thanks in advance. :) -
Hiya everyone, So yes, as the title states, I'm trying to protect images on a website from being downloaded directly (privacy problems). What I've done (or am trying to do) is something like
<a href='img.php?file=blah.jpg'>
. However, in img.php, I don't know how to tell if the image is being requested in the actual page (index.html, lets say) with the<a>
tag, or if it's requested seperately by someone who's copied that url and viewed it (in a different window, maybe). I've tried$_SERVER['REQUEST_URI']
but that returnsimg.php?file=blah.jpg
under both circumstances. Is there any way I can find out? Thanks in advance. :)You could check
$_SERVER['HTTP_REFERER']
- that should give you the URI of the page that referred to the image, as long as the user's browser doesn't have referrer sending switched off.