1

I have been trying to create a downloadable image in my webpage using download attribute but i am unable to do it. As soon as i click on the image a new tab opens with the image. I have been using this code:- <a href="image.jpg" alt="Downloadable image" download="Image">Image to be downloaded</a> I am using Chrome Browser but according to one answer a_download is now no more available in Chrome 65 so then what's the new way??

LonelyDoor
  • 28
  • 1
  • 6
  • So you're asking how you can prompt the user to download an image when the user clicks on the image? – Obsidian Age Oct 08 '19 at 03:02
  • 2
    Possible duplicate of [href image link download on click](https://stackoverflow.com/questions/2408146/href-image-link-download-on-click) – Obsidian Age Oct 08 '19 at 03:03
  • The user clicks the image and image starts to download. Thats what i am asking. I have been trying this on chrome. – LonelyDoor Oct 08 '19 at 03:11
  • There is a working example on W3Schools here https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_download – Jon B Oct 08 '19 at 03:46

1 Answers1

2

The download attribute only works for same-origin URLs. Is the file you want to make downloadable hosted on the same protocol, port, and host as the page? Even something as small as the page or file being served as http and the opposite being served as https will break it.

See more at: https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Kishore Kumar
  • 174
  • 2
  • 14