Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate Save Image As [duplicate]

How can I trigger a "Save Image As" action when an image is clicked?

like image 915
Dmytro Vasin Avatar asked Dec 06 '25 20:12

Dmytro Vasin


1 Answers

You can do it using HTML5's download attribute and no jQuery with:

<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download>
    <img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>

You can also declare the filename if you would like it to take a name other than default:

<a href="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" download="fileName.jpg">
    <img src="http://farm3.staticflickr.com/2881/10000610654_fdf29eb02f_q.jpg" alt="Smiley face">
</a>
like image 107
j08691 Avatar answered Dec 08 '25 09:12

j08691



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!