-3

Let's say I have two links to same file called hello.avi

<a href="/example.com/hello.avi">Play Movie</a>

and

<a href="/site.com/hello.avi">Download Movie</a>

when the user clicks the second link, how can I make the file to be prompted for a download, instead of opening the hello.avi file

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
user
  • 115
  • 7
  • 1
    did you tried "download" attribute in tag? – VIVEK-MDU Feb 02 '16 at 11:46
  • Download if you are using html5 – devpro Feb 02 '16 at 11:48
  • 2
    http://stackoverflow.com/questions/11353425/force-a-browser-to-save-file-as-after-clicking-link check this link – Ivin Raj Feb 02 '16 at 11:50
  • Beware that the download attribute is not understood on **Internet Explorer** nor **Safari** (source : [w3schools.com](http://www.w3schools.com/tags/att_a_download.asp)). – Anwar Feb 02 '16 at 11:50
  • Beware it is also an attribute introduced in HTML5. So you have to be using HTML5 But if @Zeratops is correct then its a useless attribute anyway – RiggsFolly Feb 02 '16 at 11:51
  • possible dublicate http://stackoverflow.com/questions/11353425/force-a-browser-to-save-file-as-after-clicking-link – Ivin Raj Feb 02 '16 at 11:52
  • @RiggsFolly here is another website that confirm the fact that this attribute is not compliant in IE/Safari : [caniuse.com](http://caniuse.com/#feat=download). – Anwar Feb 02 '16 at 11:55

4 Answers4

2

You can add Download attribute to your anchor tag as following

<a href="/site.com/hello.avi" download>Download Movie</a>
  • 2
    possible dublicate http://stackoverflow.com/questions/11353425/force-a-browser-to-save-file-as-after-clicking-link – Ivin Raj Feb 02 '16 at 11:49
0

Download file when clicking on the link (instead of navigating to the file):

<a href="test.avi" download>Click here</a>

Download file and rename it to mytextdocument.avi:

<a href="test.avi" download="mytextdocument">Click here</a>
0
<a href="/images/your-picture.jpg" download>

You should google your question before posting it here.

lacexd
  • 903
  • 1
  • 7
  • 22
0

try this one:

<a href="/example.com/hello.mp4" download>Download Movie</a>
Ivin Raj
  • 3,448
  • 2
  • 28
  • 65
  • 3
    Why should the OP "try this"? A **good answer** will always have an explanation of what was done and why it was done that way, not only for the OP but for future visitors to SO that may find this question and be reading your answer. – RiggsFolly Feb 02 '16 at 11:58