Protecting Files Problem

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
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Protecting Files Problem

Post by wizzard »

Hello,

I have made a subdir in my webroot called "spacks" because i cannot make a dir outside the root. I protected the dir with CHMOD 700 so the webusers can not access itt.I have an error if i use fpassthru.

Warning: stat failed for /home/httpd/vhosts/xxxxxxxxx/httpdocs/spacks/test.zip (errno=13 - Permission denied) in /home/httpd/vhosts/xxxxxxxxxx/httpdocs/test.php on line 5 File Not Found

Why i'm doing this is because i want when user payd they can download the file but the file has to be put in a safe dir where users cannot get it. So i want to forward via a script but i don't wanna make a copy of the file because its 50mb and thats bad for my bandwith. I already tryed alot of things but nothing works :(

Can someone helps me here?

Cheers
Kris
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

If you're using apache and can use .htaccess files put .htaccess:

Code: Select all

deny from all
into that directory. Then set permissions on the directory to 755 (depends on your host configuration).

This way your scripts still have access to file, but webusers haven't.
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post by wizzard »

I can put .htaccess in my subdirs it gives now for the users:

You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster


My question is how can i fix it via script the users can get the file but not making a copy of the original file because the files are 50-60mb.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

use fpassthru function to access such a protected directory
wizzard
Forum Commoner
Posts: 93
Joined: Thu May 16, 2002 5:36 am
Location: Belgium
Contact:

Post by wizzard »

Thanks everything is working now :)
Post Reply