1

I am trying to download an image on click and using "download" attribute of HTML5 for this. But it is redirecting the user to a new tab instead of downloading the image.

<a href="http://upload.wikimedia.org/wikipedia/commons/3/3f/Stephenson%27s_Rocket_drawing.jpg" download="myfile.jpg">Click to Download</a>

How can I sort out this issue?

halfer
  • 19,824
  • 17
  • 99
  • 186
Amrinder Singh
  • 5,300
  • 12
  • 46
  • 88
  • "download" attribute method is only available with relative files. Check the answers of this question: https://stackoverflow.com/questions/17527713/force-browser-to-download-image-files-on-click – Symphonic Aug 15 '20 at 23:05

1 Answers1

5

I tried to change the path from the href attribute to download and it worked <a href="" download="http://upload.wikimedia.org/wikipedia/commons/3/3f/Stephenson%27s_Rocket_drawing.jpg">Click to Download</a>