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?
Thanks,
Aaron
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php