php force download on mobile browsers
<p>I'm trying to force download a image file (jpg for example) using php. So I have a script here <strong>force.php</strong> and here would be the code:</p>

<pre><code>header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header('Content-Description: File Transfer');
header("Content-Type: image/jpeg");
header('Content-Length: ' . filesize($file));
header('Content-Disposition: attachment; filename=test.jpg');
readfile($file);
</code></pre>

<p>Now the problem is for some browsers (mobile phone browsers especially), it'll work properly and prompt test.jpg for the user to save. However on some browser, it'll prompt force.php as download. Any solution?</p>

<p>Thank you!</p>
