Possible Duplicate:
Force Download an Image Using Javascript
Basically I want to have the option for a user to just click a download button and download an image (rather having having to right-click or drag and drop). I read another post on here that offered a PHP solution, however if this can be done entirely in javascript I would much prefer that option. So, can it be done?
The Browsers always try to interpret the content you give them. If the Browser thinks, it can handle it, they will take the according action. In the case of an image – display it. You can’t change that behaviour. You can only trick the browser by telling him, it’s not the content he thinks it is by setting the “wrong” content-type, which forces the browser to display the “download” option. Via javascript you can only open the image in a new window and let the user download with rightclick/save as.