php - Is there any way to prevent users from seing private pictures using the absolute path? -
imagine situation
- user uploads picture see (picture public)
- user decides make picture private
- picture visible him, since picture set private on db.
there problem this:
the other users can still access picture absolute path. there way prevent this?
store images outside web root, , have php script determines if current user has permission access it, returning image contents if or 403 forbidden error if not.
you can make file look you're serving original image:
use .htaccess
:
rewriteengine on rewriterule images/(.*) image.php?file=$1 [l]
then image.php
can be:
<?php $file = $_get['file']; // use $file file information, eg. in database if( $it_exists && $has_permission_to_view) { readfile("/root/path/to/real/images/".$file); exit; } else header("http/1.1 403 forbidden");
Comments
Post a Comment