Shade Posted March 12, 2009 Share Posted March 12, 2009 Is it possible to trigger the "save image as" window, using Javascript when user clicks, on an image ? Link to comment Share on other sites More sharing options...
jeffman Posted March 12, 2009 Share Posted March 12, 2009 No. That functionality is already built in to modern browsers. Users get to choose if they want to bring up a save as dialog. Link to comment Share on other sites More sharing options...
jesh Posted March 12, 2009 Share Posted March 12, 2009 If you have server-side scripting (ASP, PHP, etc.) something like that is possible, but, like DD said, not with javascript alone. The steps would be something like:1) User clicks on the image which sends a request to a special page on your server with the image name in the query string. Something like "saveas.php?file=image.jpg".2) The special page then checks the query string to see what file to load, goes to the IO to find the file, and loads it up into memory.3) The special page then sets a few Response headers - the content-type depends on the actual file being used: Content-Disposition:attachment; filename=image.jpgContent-Type:image/jpg4) Finally, the special page then writes the contents of the file to the Response output stream and the user gets prompted with a message asking whether they want to Open or Save the file. Link to comment Share on other sites More sharing options...
Shade Posted March 12, 2009 Author Share Posted March 12, 2009 thanks DD.jesh thanks 4 replying. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.