forceful download not working for browser on Android phone on wap site
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.
ie. downloadFiles.php
Please help through this.
The ONLY way that anything should be able to download your .php source files is if your web server has some kind of misconfiguration. If other php is working via android, perhaps something in android and this file is causing the whole server to stumble and barf... But that should bring down the entire server, not simply dump the file.
Am I also missing something? This is quite the puzzle...
To make any downloads work on all (and especially older) Android versions as expected, you need to...
Read my blog post for more details:
http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
Cheers, Jpsy.
链接地址: http://www.djcxy.com/p/27798.html