So I wrote an image gallery with an option to download the original image (by default, it displays a resized version of the image). I would love to know how to I
The following code will force users to save pdf rather than viewing it with browser, I would love to achieve the same effect for the images (jpg, gif, png) by binding the click action with jQuery, how will I be able to do that?
Taken from php.net
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
html:
<div class="download">
<a href="http://www.xyz/abc.jpg">
Download original image</a>
</div>
js:
$(".download").click(function(){
// call a php to download the image
});
Is it possible to do so?
Edit: What should I do in javascript code?