HTTP Header to Force Browser Download

Mon, Mar 8, 2010 One-minute read

A content disposition header can be used to tell web browsers to ask the user where they want to save the file (and download it) instead of actually opening the file in a browser tab/window. Very handy if you want to have a download button.

Content-Disposition: attachment; filename="filename.mp3"

Tested in: Firefox, Safari, IE, Opera, and Google Chrome