How can I trigger a "Save Image As" action when an image is clicked?
            Asked
            
        
        
            Active
            
        
            Viewed 5,554 times
        
    2
            
            
        - 
                    @codefreak that question doesn't quite cover this one, because it assumes the image is already in URL form. – Dave Sep 29 '13 at 15:34
- 
                    ok how about http://stackoverflow.com/questions/12238545/how-to-save-an-image-via-javascript – codefreak Sep 29 '13 at 15:40
- 
                    2Yup, that looks better. Although it seems that back then the possible solutions weren't as elegant. – Dave Sep 29 '13 at 15:48
- 
                    +1 agreed :) download attribute is awesome – codefreak Sep 29 '13 at 15:55
1 Answers
10
            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>
- 
                    2
- 
                    @j08691 I Tried this but its not working please check my question http://stackoverflow.com/questions/31988259/download-image-on-click-in-a-preferred-name – Vignesh Subramanian Aug 13 '15 at 12:53
 
     
     
    