View Full Version : Downloading a file without opening it

07-15-2005, 11:23 PM
Dear Wizkids,

Need your help once again. I would like to get a 'Open Save ...' dialog box when the user clicks the link on my page that points to a file of known MIME type (such as .doc, .xls or .pdf etc.). I do not want the relevant application(such as Word, Excel, PPT etc.) to be opened to show the document. I dont want to keep the file without an extension on the server.

Can you please help me on this.


07-16-2005, 12:06 AM
Okay you can pass some headers in php. For example.


header("Content-Type: application/pdf; name=agreement.pdf");
header("Content-disposition: attachment; filename=agreement.pdf");

If you save a php file with those headers it will download the file that is in the filename. You can link directly to it and the open/save dialogue box will appear.