How to Force a link to Download Instead of Play in Browser

In an earlier post, I included a link to a large MP3 file on my server. I noticed that whenever I clicked on it in Chrome, the file would not download, but would simply play within my browser. That is not the behavior I wanted: playing in-browser like that over time might cause unnecessary bandwidth expenditure, but more importantly, I felt that playing in-browser would not be as convenient for some users that wanted to simply download the file. I wanted to give the user the option. Anyway, it’s really easy to force an HTML-5 enabled browser (like Chrome) to force a link to download a file instead of playing in-browser. All you need to do is include the word “download” anywhere in the anchor tag:

<a download href="yourfile.mp3">Download this File!</a>

Now if only all things were that easy.

This entry was posted in minutiae. Bookmark the permalink.

Leave a Reply

Your email address will not be published.