how do I force users to download image (like downloading pdf)?
<p>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 </p>

<p>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?</p>

<p>Taken from php.net</p>

<pre><code>&lt;?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');
?&gt;
</code></pre>

<p>html:</p>

<pre><code>&lt;div class="download"&gt;
&lt;a href="http://www.xyz/abc.jpg"&gt;
    Download original image&lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>js:</p>

<pre><code>$(".download").click(function(){
  // call a php to download the image
});
</code></pre>

<p>Is it possible to do so? </p>

<p>Edit: What should I do in javascript code?</p>
