Reputation: 5482
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?
Upvotes: 4
Views: 6058
Reputation: 596
Most browser (Chrome, Firefox) block download from CORS origin (external domains) for safety reasons.
So instead of a "silent" download, they force the user to navigate to the screen.
Upvotes: 1
Reputation: 81
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>
Upvotes: 8