Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open the Save Image dialog using jQuery/Javascript?

When a user clicks on an image on a web page, I'd like to trigger the browser's Save Image dialog and to let the user save the image on their hard drive. Is there a cross-browser way to do this with jQuery/Javascript?

like image 294
John Mac Avatar asked Dec 30 '08 03:12

John Mac


1 Answers

Not precisely, but you can do it by hyperlinking to the img file and setting the content-type and content-disposition headers in the server response. Try, e.g., application/x-download, plus the other headers specified here.

like image 172
Craig Stuntz Avatar answered Sep 30 '22 20:09

Craig Stuntz