Re: Block direct image loads but allow them in PHP

From: Date: Sat, 15 Feb 2003 15:55:59 +0000
Subject: Re: Block direct image loads but allow them in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-135673@lists.php.net to get a copy of this message
On Sat, 2003-02-15 at 11:00, Michael Mulligan wrote: > Hi > > I have a bit of a problem which might just be due to my lack of knowledge > with Apache. Basically, what I want to do is to *not* allow users to enter > particular URLs in their browser (namely to *.jpg and *.xml files under a > particular directory, let's call it "imagesDir"). However, I can't simply > Deny all or stick a .htaccess in the folder because I *do* want these images > to load from within a particular PHP file I have coded. I guess the easiest would be to filter those images through a php script. Your PHP script would perform whatever checks are needed (for example, you could check ther HTTP_REFERER variable, or a shared token with the originating PHP script) and then output the image only if it's appropriate to do so. This way, your images would not be accessible to your users at all--unless you wanted them to be. Cheers, Marco -- ---------------- php|architect - The Monthly Magazine for PHP Professionals Come check us out on the web at http://www.phparch.com!

« previous php.general (#135673) next »