14 Jan 2010 Ferado

How to force a download with a “Save As” prompt using a .htaccess file and/or Apache

This is an oldie but a goody. In web development there comes a time when you need to force a download when someone clicks on a link, without telling them to “right click save as…” In the past this was always a problem. Now thanks to Google, you can type in keywords and find a nice, lovely blog post like this one and figure it out. And of course you’re not going to tell anyone because you want to look like a Rock Star. So you’re going to say “ain’t nothing but a thang.”

And before you do that, here’s how you’re going to save the day and prompt a “Save As” to the user so he/she can download his/her file:

[cc lang=”ini”]

# Put all your extensions after the word stream
AddType application/octet-stream .doc .mov .avi .pdf .xls .mp4 .xlsx .docm

[/cc]

Continue reading “How to force a download with a “Save As” prompt using a .htaccess file and/or Apache” »