php - How to keep users from viewing images by URL? -
imagine have image file secretimage.png
on webspace , want several users have right access image on index.php
. can done:
// index.php if($userisallowed) echo '<img src="secretimage.png" />';
the problem is, users theoretically still access image browsing directly www.mydomain.com/secretimage.png
. there way prevent them doing so, image can viewed inside index.php
?
you can use htaccess route requests specific folder through .php file. in file, can determine whether user can see file or not... if so, deliver correct headers , image. if not, show whatever want (404, placeholder image).
Comments
Post a Comment