I would like to allow the user to directly download a file with a single click. There is however a problem when it comes to known meme-types like HTML, audio, video, etc. Id
There is a new download
attribute in HTML5 that you can annote links with. It indicates to the browser that the resource should be downloaded rather than navigated to. Right now, it only works in Chrome, but it is part of the HTML spec and will hopefully be adopted by other browser soon.
Demo: http://html5-demos.appspot.com/static/a.download.html More info: http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download
You can use <a href="example" download>
. This is HTML5 and it works with Chrome, Firefox and Edge (but not with Internet Explorer, not even modern versions).
If someone reaches this question now the best solution is
<a href="example" download target="_blank">
If the browser supports the HTML5 attribute download will start the download of the file, otherwise (in case of Internet Explorer and old browsers) the link will open another tab window with the file to download.