Reputation: 1951
How do you make an MP3 link download instead of play "in-browser"?
I tried changing the target to blank, but that just opened the player in a new window.
Upvotes: 4
Views: 1874
Reputation: 239682
For quite some time (Chrome 14+, Firefox 20+, Edge 44+) it is possible to use the download attribute on same-origin links to force download behavior even when the server doesn't supply a Content-Disposition
header on the link target.
Upvotes: 0
Reputation: 764
I could be wrong, but I've seen people with the same problem before just with other file types, they used the code below:
<FilesMatch "\.(?i:mp3)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
Hope this works for you!
Upvotes: 0
Reputation: 57209
Lots of solutions here. Here's the basic idea:
Upvotes: 2
Reputation: 19988
Without access to the server generating the HTTP responses, the browser gets to decide what to do with different types of responses. usually the only files a browser will download are things like .zip
files which it cannot display.
Upvotes: -1
Reputation: 55334
If your server supports PHP, create a PHP script called "getfile.php" (or similar) that takes a parameter of a file ID or file name. Set the content-type
and content-disposition
headers within the script to force a download prompt.
See: http://webdesign.about.com/od/php/ht/force_download.htm
Upvotes: 3
Reputation: 168958
You can't do this by modifying the link. You will have to have the HTTP server that serves the file send a Content-Type
of "application/octet-stream". Presumably it is sending the type "audio/mpeg", which is hinting to the browser that it is MP3 content. Without the capacity to alter this header, you can't achieve this.
Upvotes: 5