Posted by David on 11/02/06 19:09
Thanks.
On 2 Nov 2006 00:55:43 -0800, "Mateusz Markowski"
<mateusz@bsdmail.org> wrote:
>
>David napisal(a):
>> Is there a way to download a file from a directory not in the server's
>> path? Eg. not under public_html? This would be for security so that
>> the files can never be directly access vial the web.
>>
>> I did a search on PHP + download but this garnered many unless web
>> sites.
>>
>
>Yes, there is. You can use header() with readfile(), for instance:
>
>//file to send
>$file = '/etc/passwd';
>
>//headers to tell browser that we want to send file
>header('Content-Type: application/octet-stream');
>header('Content-Length: ' . filesize($file));
>
>//reads file and sends it to client
>@readfile($file);
[Back to original message]
|