|
-
May 12th, 2005, 02:14 PM
#1
Thread Starter
Frenzied Member
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
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 12th, 2005, 03:29 PM
#2
Fanatic Member
Re: Access protected directory
This might be what your looking for... Direct from the php manual
http://us2.php.net/features.http-auth
-
May 12th, 2005, 03:36 PM
#3
Thread Starter
Frenzied Member
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
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 12th, 2005, 03:42 PM
#4
Fanatic Member
Re: Access protected directory
Maybe there is something on this page that can help you
http://www.php.net/manual/en/ref.filesystem.php
-
May 12th, 2005, 04:03 PM
#5
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?
-
May 12th, 2005, 04:15 PM
#6
Thread Starter
Frenzied Member
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
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
-
May 12th, 2005, 05:39 PM
#7
Re: Access protected directory
The PHP script wouldn't need the password, unless it for some reason uses HTTP to access those files.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
May 13th, 2005, 09:03 AM
#8
Thread Starter
Frenzied Member
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
Now happily married and still crankin' away at the keyboard.  Life is grand for a coder, no?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|