php force download on mobile browsers

fede1190

New Member
I'm trying to force download a image file (jpg for example) using php. So I have a script here force.php and here would be the code:\[code\]header("Pragma: public"); // requiredheader("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0");header("Cache-Control: private",false); // required for certain browsersheader('Content-Description: File Transfer');header("Content-Type: image/jpeg");header('Content-Length: ' . filesize($file));header('Content-Disposition: attachment; filename=test.jpg');readfile($file);\[/code\]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?Thank you!
 
Back
Top