Really quick but useful tip today…
I’ll sometimes require the need for certain files on my websites to be automatically downloadable. By that, I mean the user will be prompted to download (or open) the file upon visiting a link to it.
For example, you may have a collection of PDFs, that you want users to download, fill in, and email to you.
Generally with older browsers, filetypes like PDF, DOC, MP3, etc would automatically prompt a download anyway. However, newer versions of Firefox, Chrome, etc, can display documents in browser, playback music, plus a whole lot more.
So, to force a download, you’ll need a htaccess file on your website.
Then simply add the following code to the htaccess:
AddType application/octet-stream .pdf .doc
You can change “.pdf” and “.doc” to different filetypes, or add further filetypes which you only need to separate with a space.
Job done!