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?
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>
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.
-source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With