I have a wapsite where I am implementing forceful download.
The script is in PHP
It works great for all the other mobile browsers, but when I access the site using Android phone, it downloads the actual PHP file.
Following is my code snippet of file downloadFiles.php.
$fileExt = "jpg";
$strOrgFileName = "abc.jpg";
switch($fileExt)
{
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "zip": $ctype="application/zip"; break;
default: $ctype="application/force-download";
}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: $ctype");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=\"".$strOrgFileName."\";" );
readfile($strOrgFileName);
In Android system it downloads the PHP file.
i.e. downloadFiles.php