Reply to Re: Password protecting downloads

Your name:

Reply:


Posted by Jim Michaels on 02/06/06 05:35

"Iain Napier" <emailaddressisinvalid@aol.com> wrote in message
news:XNednQLDfMJoGD7eRVnyuQ@pipex.net...
> alex wrote:
>>
>> Secondly, you can store the files outside of the webroot.. sounds like
>> you're using shared hosting here, so instead of putting the files in your
>> public_http, put them somewhere else, then your download script just
>> sources that file, whereever it is (fopen) and sends it..
>
> I've just realised I can change permissions on this server, so if I create
> a subdirectory in wwwroot called privatearea, put my file1.zip in there
> and remove the public read permission, a web browser can't get it's hands
> on it.
>
> Now, I create a test.php in the same directory as file1.zip and using
> $_SERVER['PATH_TRANSLATED'], I get the full file system path to where my
> files are. So:
>
> $file="/full/path/to/my/wwwroot/privatearea/file1.zip"
> if ($file_handle=fopen($file,"r")) echo("PHP can read the file!");
>
> And I see PHP can read the file okay, but web browsers don't get direct
> access to it.
>
> Presumably I can now use fopen to send the data back via PHP?

a better function might be readfile() because it reads the file and outputs
straight to the browser. all you need before it is header()s.

>
> Thanks for the pointer in your first post, I seem to be on the right track
> now I hope. Tomorrow I'll try and work out how to have PHP send the file
> back.. 3.30 am now :-\

[Back to original 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

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