interact with .htaccess
| From: | Miguel Angelo | Date: | Mon, 16 Jun 2003 08:17:00 +0000 |
| Subject: | interact with .htaccess | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-151677@lists.php.net to get a copy of this message | ||
Hi People
That is a very good idea, i was thinking about using something similar on a
file sharing area...
But James, do you know how can we use this to build pages....
i mean include images on a html pages on a restricted way
kind like
<image="/somewhere/mysecretfile.jpg">
Do you know how i can safely restrict file acess and still link this files
into a html page, this would for example allow showing a album of photos to
some users but not all site users.
By the way i'm building a new personal web page and will share the code in a
open source i think it would be good for newbies like me
Thankx any way
Miguel
From: James Hicks <freedomadvocate@cox.net>
To: " Peter Berglund" <peter_b@telia.com>
Date: Sun, 15 Jun 2003 10:55:33 -0400
CC: php-general@lists.php.net
Subject: Re: [PHP] Re: interact with .htaccess
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);
?>