Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] web file download



Hi Blu,

I'm writing a web application which downloads files using PHP. The trick 
to getting a file to download using your browser is to send it a key set 
of header messages which tell the browser that a file is on its way. 
I've poked around the web to find several example of the headers that 
one needs to send, but as usual, there seems to be more under the 
surface than the simple 3 line example.

The most comprehensive set of header commands I've seen to initiate a 
file download is the following...

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment;filename="'.$Filename.'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: '.$FileSize);
header('X-SendFile: '.$StorageDirectory.'/'.$UUID);
exit();


My question to the web experts is what is really needed to be sent using 
the PHP header function in order to get a file across properly. I'm 
wondering about the 'Expires:', 'Cache-Control:', and 'Pragma:' headers. 
What are they needed for and how do they make the transfer work better.

Any general comments on this is greatly appreciated.

Thanks!

Steve.



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org