password protect folders

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

password protect folders

Post by manRay »

I need a way to protect folders with user content inside. I need some way of keeping a users content in an easy to retrieve style but also protected so that way they are the only one able to get inside the folder when they login. Any ideas?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: password protect folders

Post by Christopher »

What web server are you using? HTTP Authentication is pretty easy to setup. Often you host will have a way to configure it from some control panel.
(#10850)
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: password protect folders

Post by manRay »

I am using a linux web server provided by godaddy.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: password protect folders

Post by manRay »

Anyone else have any input?
rhecker
Forum Contributor
Posts: 178
Joined: Fri Jul 11, 2008 5:49 pm

Re: password protect folders

Post by rhecker »

The Apache manual provides details on the use of htpasswd for the creation of an encrypted password file. You then place the resulting file above the web root. Then place the .htaccess file in the directories you wish to protect. They should look something like this:

Code: Select all

authtype basic
authname ADMIN
authuserfile /data/18/1/130/82/265411/user/958741/cgi-bin/.file
require valid-user
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: password protect folders

Post by manRay »

How do sites like photobucket protect users' images from others? I want to do something like that.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: password protect folders

Post by manRay »

So how would I open a file in a the protected folder from a script.
Post Reply