Access protected directory
I need to be able to protect a directory so that only my PHP script can access it. (I have files in there that I don't want to have downloaded unless I know about it.)
How can I give my PHP script the username and password to access this file?
or would it be better if I did an FTP sort of thing? How would I do this?
Squirrelly1
Re: Access protected directory
This might be what your looking for... Direct from the php manual
http://us2.php.net/features.http-auth
Re: Access protected directory
I'm not wanting to protect a file that I'm creating... I'm wanting to access a directory that is already protected in order to download files... I don't want my user to be able to go in and download files directly from the directory without my script.
Squirrelly1
Re: Access protected directory
Maybe there is something on this page that can help you
http://www.php.net/manual/en/ref.filesystem.php
Re: Access protected directory
Are you using Apache? If so, create a file called .htaccess in the directory you want to protect and add the following lines:
Code:
Order allow,deny
Deny from all
You want to add a username an password. How do you want to implement this? Do you want to enable access by multiple users and passwords or just protect the script with a generic password?
Re: Access protected directory
I just want to put in a password that no one knows about except for me and be able to pass that username and password to the webserver from my php script instead of asking the user for it...
squirrelly1
Re: Access protected directory
The PHP script wouldn't need the password, unless it for some reason uses HTTP to access those files.
Re: Access protected directory
Well, how I was having it work was to use something like
<header "Location: http://www.whatever.com/file.ext">
to download the file...
Is there a way to do this that wouldn't require redirection?
Thanks,
Squirrelly1