I have a PDF file that I am trying to link to and I need to have visitors automatically download it instead of it opening inside the browser. Is there a way to do this without zipping it. I was thinking that there may be some php headers or something that will do it. I can pre-make it into a pdf, or I can generate one in php on the fly, if it matters. Any suggestions would be appreciated.
Here's a copy and paste of a section from http://www.faqts.com/knowledge_base/view.phtml/aid/4906 : Using the Content-Disposition header correctly should force IE and other browsers to treat the file as an attachment/download. I do it all the time. Make sure you specify attachment as the type. ex: Content-Disposition: attachment; filename="file.pdf" Obviously this is easiest if you are dynamically outputing the contents of the PDF from a server script script (like Perl, PHP, ASP, etc). So yeah, have a sniff around the content disposition header...
Ok, I found a way to do it within php. Works well in Mozilla and IE. header("HTTP/1.1 200 OK"); header("Content-Length: $file-size"); header("Content-Type: application/force-download"); header("Content-Disposition: attachment; filename=$file-name"); header("Content-Transfer-Encoding: binary"); PHP: