Re: Re: alternative to protecting files through http auth.
| From: | Scott Taylor | Date: | Sat, 17 Jan 2004 17:59:57 +0000 |
| Subject: | Re: Re: alternative to protecting files through http auth. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174933@lists.php.net to get a copy of this message | ||
Subject:
Re: [PHP] Re: alternative to protecting files through http auth.
From:
Jason Wong <php-general@gremlins.biz>
Date:
Sat, 17 Jan 2004 05:08:29 +0800
To:
php-general@lists.php.net
On Saturday 17 January 2004 04:03, Scott Taylor wrote:
Alternately, if you aren't able to create directories or access files outside the DocumentRoot for your site, you can create an unbrowsable storage directory protected with a .htaccess file. If the filesystem permissions are correct, your PHP script will be able to read contentCould you explain what, exactly, does not work?from that directory, because PHP code isn't subject to .htaccess rules.It actually does not work.
The above outlines a scheme which is workable. Could you describe the steps you took to implement said scheme which lead you to the conclusion that "It actually does not work" ? Yes, sorry. Here is the code: $file = 'http://miningstocks.com/protected/archive/Dec03PostPress.pdf'; //now view the PDF file header("Content-Type: application/pdf"); header("Accept-Ranges: bytes"); header("Content-Length: ".filesize($file)); readfile($file); I can send the rest if necessary. You can see the results yourself of this: http://miningstocks.com/enteremail.php (just enter a@a.com for an email address). Yet, when I have changed the $file to hold a path that is not protected through http auth. it works perfectly fine and loads the file. Best Regards, ScottI am trying to load a PDF file. I've tried to load it from a protected directory loading it with headers, but this fails if the protection is on. Does this make sense to you?