Reputation: 3
I've been trying to create a website that allows users to upload word documents.. Those documents would then be stored in a public directory of the website. The thing is, I don't want everyone to access the uploaded documents.. I would like to check if they are logged in first, and if they are "Authorized Users".. say if they have account level of 50 or higher, then they are allowed to open the directory..
Is there anyway I can do this through .htaccess?.. or is there a better solution?
I don't know if this is a dumb question, but do help me please. I would deeply appreciate any help I can get right now.
Note:
Sorry for not mentioning earlier, but I actually want to use google docs for viewing these documents in order to embed them in my website.
Upvotes: 0
Views: 1109
Reputation: 101
It sounds like you're taking the approach of putting the public documents directory somewhere underneath your web root directory. For a number of reasons (security, portability, maintainability), this is not the best approach to take.
Here's a quick-and-dirty approach (I'm assuming that you're already handling user authentication using a database or some other means to store credentials):
scandir()
(http://www.php.net/manual/en/function.scandir.php)readfile()
(http://php.net/manual/en/function.readfile.php), making special note in the example of setting the various header fields.Upvotes: 2
Reputation: 1024
You'd want to probably use a database (MySQL?) and PHP sessions to check if:
if($level >= 50)
Upvotes: 0