Re: readfile()
| From: | Aaron Todd | Date: | Mon, 23 Aug 2004 20:35:44 +0000 |
| Subject: | Re: readfile() | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194530@lists.php.net to get a copy of this message | ||
Not too familure with a chroot'd web setup and I dont know if my ISP has
some security that I dont know about. I tried some tests with file_exists()
and it doesnt seemt to be able to get to the files either. I've put in an
info request to my ISP but they are usually not much help with something
this advanced. Is there anything else I can do to further diagnose this
problem?
Thanks again,
Aaron
"Greg Donald" <greg.donald@nukote.com> wrote in message
news:1093285051.2745.58.camel@localhost...
> 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