user1965834
user1965834

Reputation: 21

html5 download attribute not working in FF

Hi I have an anchor tag with download attribute which when clicked downloads the image from the url defined in href. This works fine in Chrome but in Firefox it takes to the image in the browser. Is there any way we can make this work in FF

<a href="https://www.ricoh.com/r_dc/r/r8/img/sample_10.jpg" download="JPG">image</a>

Upvotes: 2

Views: 640

Answers (1)

Henrik Karlsson
Henrik Karlsson

Reputation: 5713

The problem with this is that in Firefox this only works for files with the same origin. From MDN:

In Firefox 20 this attribute is only honored for links to resources with the same-origin.

I see three solutions:

  • If you own the target image and has control over it, you should serve it from the same domain as the page where you put the link.
  • Set up a reverse proxy to serve the images through the same origin
  • Again, if you own the target site, you could serve it with a Content-Type: application/octet-stream header which will force the browser to download the image regardless of how the download link looks

Upvotes: 4

Related Questions