You are here: Re: Password protecting downloads « PHP Programming Language « IT news, forums, messages
Re: Password protecting downloads

Posted by Iain Napier on 12/17/05 13:47

alex wrote:
>
> here is a bit of a script i use to open an a file and send it to the
> client.. you can use this to help.. (keep in mind, when we send
> headers, they must be the first thing sent, you can't have any output go
> to the client first) (also, using this method, i always use the ob
> buffer.. so all the headers and file stream are sent at the same time..
> works this way for me.. ymmv
>
> #------------------------------------
> ob_start();
> header('Content-type: application/x-gzip');
> header('Content-Disposition: attachment; filename="' . $file . '"');
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> header("Cache-Control: post-check=0, pre-check=0", false);
> header("Pragma: no-cache");
> readfile($dir . $file);
> ob_end_flush();
> #------------------------------
>
> be sure to modify the content-type for whatever you're sending

That's worked brilliantly.

I've removed the world read attribute for all the files, and used your
chunk of code there to look at their absolute path on the web server.
No clients can view them directly via a browser, but they can read them
fine going via authentication then your script.

Just want I wanted! Many thanks :-)

 

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

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