Php Android默认浏览器不支持';t从PC localhost下载.txt文件

Php Android默认浏览器不支持';t从PC localhost下载.txt文件,php,android,browser,Php,Android,Browser,我在Wamp服务器上运行的PHP上编写了一个脚本,强制下载.txt文件。脚本如下所示: header("Content-Type: application/octet-stream"); $newfile = "data.txt"; header("Content-Disposition: attachment; filename=" . urlencode($newfile)); header("Content-Type: application/force-download"); h

我在Wamp服务器上运行的PHP上编写了一个脚本,强制下载.txt文件。脚本如下所示:

header("Content-Type: application/octet-stream");

$newfile = "data.txt";
header("Content-Disposition: attachment; filename=" . urlencode($newfile));   
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");            
header("Content-Length: " . filesize($newfile));
flush(); // this doesn't really matter.
$fp = fopen($newfile, "r");
while (!feof($fp))
{
    echo fread($fp, 65536);
    flush(); // this is essential for large downloads
} 
fclose($fp);
该代码运行良好

但问题是,我已经将我的Android设备连接到PC,并且可以使用任何其他浏览器下载此文件,但不能使用Android默认Web浏览器


有人知道为什么在默认浏览器上下载失败吗?但是可以在Android上从其他浏览器下载吗?

由于某些原因,Android浏览器对HTTP头非常挑剔

本页将为您提供有关该问题的一些见解:

引用页面的一部分,如果使用这行代码,它可能无法工作

内容类型:应用程序/强制下载

本页还提供了一些可能的解决方案