954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Download A file

If I want my users to download a .zip or .exe file the command is

Download
or
Download

This will ask the visitors where to save the file on their hard disk.

But what if I want my users to download a doc/pdf/php/html file and I dnt want the browser to display these on the the browser itself but ask the users to save them.

Download will simple display the page on the browser.


PS: I dont wanna compress them.

Any help appreciated

cancer10
Posting Whiz in Training
234 posts since Dec 2004
Reputation Points: 58
Solved Threads: 1
 

The only thing you can really do is to either change the extension to something the browser won't read and will just download, or tell them to click File>Save As.

DennisP
Newbie Poster
23 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

Actually, if you have

[php]
<?php
header('Content-type: application/msword');
header('Content-Disposition: attachment; filename="file.doc"');
readfile('file.doc');
?>
[/php]

then it will force the browser to save the file with the appropriate name. You can replace content-type with whatever mime type is appropriate

You can view mimetypes by searching the net, or referencing the following:
http://www.webmaster-toolkit.com/mime-types.shtml

MCP
Light Poster
44 posts since Oct 2006
Reputation Points: 14
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You