Re: Strategy to protect images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is how I do it:

1) put image files in folder that is not accessable from browser, like outside of http root dir.

2) in the img src tag point src to script like <img src="/image.php?imageID=$someID">
where $someID is the id of image or name of image you want user to see

3) the image.php script will have the function to make sure that user has right to access the image, for example the user is logged in.
if user has the right to view the image then do something like this:

$pathtoimage is the full path you have to calculate based on image name or imageID
$strFile = file_get_contents($pathtoimage);
   if($strFile)
   {
       header('Content-type: image/jpeg' );
       echo $strFile;
   }



Stefano Esposito wrote:

Hi all,

i have to forbid users of my site to view images directly (i.e.
writing the image URL in the address bar) but they'd be able viewing
them from the pages of the site. What's the best way of doing it, or
something similar? Is there a common strategy using PHP? Thank you for
any hint :-)

Ciao,
Stefano


--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
VOGLIA DI VACANZE ? * A Riccione i Family Hotels sono gli alberghi specializzati per le vacanze dei bambini
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=7984&d=15-6



--

Open Source ALL content management
with streaming video
http://wiki.sharedlog.com



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux