2

I put mp3 and mp4 files on my website with audio/video html5 tags. I want this files can be download by users, and Chrome display a download button to do this, so its ok.

But i've some users using IE and firefox, and they dont have this button. Is there a way to display it or is it just a chrome feature ?

I try to add a download link to the media file with download="download" html5 attribute, but it open the file in a player on a new tab.

How can i do to force IE and firefox to download the files ?

Thanks a lot

1 Answers1

1

The download button you see is part of the default HTML5 player built into Chrome. How the browser presents such an element is up to it. Browsers may differ on this, as you have seen.

The best thing to do is to do exactly what you're doing... offer a link with a download attribute. Not all user agents will respect this, and ideally, it's up to them what to do. Ideally, they'd do what you would expect as well.

A third option is to use a Content-Disposition header in your HTTP response for MP3 files. It looks something like this:

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

A fourth, absolutely terrible do-not-use-unless-you-have-to option is to use a generic Content-Type header.

Content-Type: application/octet-stream

Since the browser has no way of knowing what the content is, it will usually open a save dialog. (It will some times use content type sniffing though to figure out what the file is, and ignore your header.)

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Thanks Brad, My problem is that files are on a partner server so i cant modify response from it. I think i must create a "proxy url" like my_server.com/get_media/the_media.mp3 which will get the file to the other server, and send it to the user with modified headers ? – Fabrice Kimmel Apr 17 '18 at 09:14
  • Yes, that's the only other way. – Brad Apr 17 '18 at 16:08
  • +1. Brad, it seems like my question might be a slam-dunk for you, and I was wondering if you'd mind taking a quick look: https://stackoverflow.com/questions/54738875/html5-audio-says-live-broadcast-in-ios-when-its-a-static-file – Ryan Feb 18 '19 at 00:28