Welcome Guest, Not a member yet? Register   Sign In
How to restrict access to images
#3

[eluser]rossj81[/eluser]
CHMOD is the easiest way of restricting access, but won't help if OP wants to base access on $_SESSION.

I would create http://www.mywebapp.com/images/imagecont...eimage.jpg completely separate from your CI instance. Then, place the actual image files in either (a) a subfolder CHMODed so that only local users have access, or (b) a folder outside of your www directory so that Apache will never serve it.

Then, get your PHP script to validate $_SESSION, read the image file, then serve it as an image:

Code:
header( "Content-type:image/jpeg" );
header( "Content-Disposition:inline ; filename=secure.jpg" );
imagejpeg( $img );
imagedestroy( $img );

Edit: note this might have a performance impact, as you're running every image through PHP


Messages In This Thread
How to restrict access to images - by El Forum - 05-03-2014, 04:54 AM
How to restrict access to images - by El Forum - 05-06-2014, 05:54 AM
How to restrict access to images - by El Forum - 05-09-2014, 09:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB