Page 1 of 1

Protecting Files Problem

Posted: Fri Nov 21, 2003 4:44 pm
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

Posted: Fri Nov 21, 2003 5:28 pm
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.

Posted: Sat Nov 22, 2003 3:46 am
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.

Posted: Sat Nov 22, 2003 12:49 pm
by Weirdan
use fpassthru function to access such a protected directory

Posted: Sat Nov 22, 2003 12:58 pm
by wizzard
Thanks everything is working now :)