PDA

View Full Version : php force download dialouge prompt


chriskq
02-29-2008, 04: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

davidj
02-29-2008, 06:57 AM
<script>

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



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