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
In your filename.php file before sending the contents to the visitor, add several header lines that will tell the browser what do to with the content. For example: header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="downloaded.pdf"'); readfile('my_pdf_file.pdf'); PHP: A comprehensive list of MIME types to be used in conjunction with the "Content-type" header can be accessed here.