LonelyDoor
LonelyDoor

Reputation: 40

How to create a downloadable file without using download tag in html?

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??

Upvotes: 1

Views: 199

Answers (1)

Kishore Kumar
Kishore Kumar

Reputation: 184

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

Upvotes: 3

Related Questions