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

<a href=filename.exe>Download</a>
or
<a href=filename.zip>Download</a>

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.

<a href=filename.php>Download</a> will simple display the page on the browser.


PS: I dont wanna compress them.

Any help appreciated

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.

Actually, if you have

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.