Our website contains many photos that users can retrieve. Currently they have to click on the thumbnail of their photo which opens a new browser window with their photo at full scale. Then they have to right-click -> Save as... to download.
Is it possible to tell the browser not to open the photo in the new window, but to prompt the open/save dialog when they click on the thumbnail? I'd like to do this without giving the file a wierd extension or zipping it. Is there an http header to set or am I out of luck?
Thanks,
Jason
Jason E. Brawner<br />Sun Certified Java Programmer<br />Sun Certified Web Component Developer
When the user clicks on the thumbnail, submit to a servlet that returns the full-size image as a byte stream with the appropriate content type set onto the response.
...but if I provide the appropriate content type (image/jpeg) won't the browser recognize it and display the photo rather than prompt for download? And if it did work, the user would be presented with a weird default file name (probably the servlet mapping) in the 'Save as' dialog. They'd have to be instucted to put a .jpg ext on the file before they saved it to their hard drive... too confusing for the average user.
Regardless, I will try it tomorrow.
Thanks
Jason E. Brawner<br />Sun Certified Java Programmer<br />Sun Certified Web Component Developer
You could always change the content type to something other than "image/...".
Alternatively: consider that most users don't expect clicking on images to download them. They expect to see them. And a good number of them would know what to do to save the image if they needed to.
refreshing change from the constant questions on how to PREVENT people from saving images displayed in their browsers
A good way that works is to serve the image in a format that browsers can't display. BMP and TIFF are good examples (though there's no guarantee that there are no browsers at all that can't show them of course).
Also set the 'content disposition' so that the browser knows that the response is a file (you can even name it) attachment. Search for 'content-disposition' for examples.
thanks for the ideas.... the only reason I need to investigate this approach is because a client wants their site to work this way, even though it is a bit silly.
Thanks,
Jason
Jason E. Brawner<br />Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
New web page for Paul's Rocket Mass Heaters movies