I am currently working on a website that users can download binary media files from (mainly .mp3). We need a way for a “Download” button to save the file to the user’s specified location in their browser’s preferences, and it needs to somehow display a progress bar.
Currently, all I’m worried about is finding a way to implement this using HTML5 and doing it in such a way that in future versions we will later be able to access that stream so that once we get this basic download part coded, we can somehow implement a progress bar in the future.
I know HTML5 has a File API, but very few browsers currently allow its implementation, and we need this to work on IE 7+ and regularly used versions of Chrome and Firefox.
Thanks for your help!
HTML5 supports the
downloadattribute: http://webreflection.blogspot.com/2011/08/html5-how-to-create-downloads-on-fly.htmlExample:
Clicking on this will allow the browser to handle the download (instead of opening the file using whatever application is associated with the mimetype), including a progress bar.
Note: You really want to be careful not to deviate from normal user expectation by trying to create your own implementation. This is synonymous with forcing a link to open in a new tab–it can be confusing to the user if they are expecting one behavior but receive another. In your case, try to specifically explain that this will be a “download” link, not a “play” link. The example above does this, but a “download” icon might also suffice.