On Mon, 2004-08-23 at 13:02, Aaron Todd wrote:
> I'm trying to use readfile() to allow a user to download a file that is
> outside of my webroot.
>
> webroot = /var/www/html
> downloads dir = /var/www/downloads
>
> Here is the code that I have been using:
> $file = "/var/www/downloads/test.txt";
> header("Content-Description: File Transfer");
> header("Content-Type: application/force-download");
> header("Content-Disposition: attachment; filename=".basename($file));
> readfile($file);
>
> This code will work if I change the path to the webroot path, but not the
> downloads dir path. I get an error saying "Unable to access" and then
> "failed to open stream: No such file or directory".
>
> I have given whe I believe is the correct rights for the downloads dir and
> also the file...rwxr-xr-x for both.
>
> Anyone have any idea why this isnt working?
Is the download directory outside a chroot'd web setup perhaps? Or
maybe your provider has some security you don't know about?
There are some file related functions you can debug with, like
is_readable(), and file_exists().
--
Greg Donald
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php