Re: Re: interact with .htaccess

From: Date: Sun, 15 Jun 2003 14:55:33 +0000
Subject: Re: Re: interact with .htaccess
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-151583@lists.php.net to get a copy of this message
I think what you really want to do is place your downloadable files in a directory that is not in your httpd's document root and use a password protected PHP script to access these files and send them to the user after authentication. I think you could accomplish this with the fpassthru() function and the correct header. htaccess is just going to get in your way. <? include("authentication.php"); $filename="/path/to/directory/not/in/httpd/doc/root/mysecretpicture.jpg"; $fp=fopen($filename, "rb"); header( "Content-type: image/jpeg\nContent-Disposition: inline; filename=\"mypic.jpg\"\nContent-length: ".(string)(filesize($filename)) ); fpassthru($fp); ?> You've got to make sure that the user that your httpd runs as has permission to access /path/to/directory/not/in/httpd/doc/root/ James On Sunday 15 June 2003 10:32 am, Peter Berglund wrote: > ok, I change my question, how do I protect downloadable files from users > that are not valid? > without the use of htaccess? > > "Peter Berglund" <peter_b@telia.com> skrev i meddelandet > news:20030615102836.9660.qmail@pb1.pair.com... > > > I want to send user and password from php to a protected directory. > > For example: If I go directly to the directory I get a popup to enter > > user and password, the normallt way. > > > > But if I go through a php-script that checks if I'm a valid user from a > > database I will get access to the folder. > > > > So i need a way to send user/password from php to the .htaccess file.

« previous php.general (#151583) next »