You are here: Re: Downloading from a directory not in the server's path? « PHP Programming Language « IT news, forums, messages
Re: Downloading from a directory not in the server's path?

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);

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация