PDA

View Full Version : Auto-Download HTML files



ashben
January 18th, 2001, 23:03
Is it possible to have HTML (*.html or *.htm) files automatically download (with the Save As dialog box) instead of being parsed by the browser. For example if someone visits an HTML page with some information on it, I wish to provide them with a link to download the same html file onto their machine. The solution has to work on both IE and Netscape.

Koolguy
January 18th, 2001, 23:48
I don't think that would be viable, however it might be possible to do with php, i once did a project that allowed a txt file to be downloaded instead of opened.

ashben
January 19th, 2001, 03:27
Can you please tell me how you did it in PHP? It would be very helpful!

razor
January 19th, 2001, 05:53
using a header on the top of the php page like:

header( "Content-type: application/x-gzip" );
header( "Content-Disposition: attachment; filename=some-file.tar.gz" );
header( "Content-Description: PHP3 Generated Data" );

ashben
January 20th, 2001, 00:27
Thanks a ton. The "Content-Disposition" header definition works just fine. I researched a bit more on it and got it to work for PDF's and DOC's as well.