View Full Version : php force download dialouge prompt

02-29-2008, 03:43 AM
lets say i have an image wrapped in an a tag.

i would like on click on the image to prompt the save as dialouge box (eg: if your were linking to a pdf this would happen automatically) so in essence forcing the user to download the image.

i heard on the grapevine it might have something to do with content disposition or mimetypes.

anybody done this before

02-29-2008, 05:57 AM

function save(img) {
if (typeof img == 'object'){
img = img.src;
window.win = open(img);
setTimeout(win.document.execCommand('SaveAs'), 500);

<a href="#" onclick="save(document.getElementById('Image')); return false" ><img src="Images/auditt.jpg" width="400" height="300" id="Image"/></a>