我正在做一个脚本,增加APK文件下载的计数器,然后将文件发送到浏览器进行下载。apk文件强制下载头文件
这是我有:
<?php
$file = "android.apk";
function force_download($file){
header("Pragma: public", true);
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment; filename=".basename($file));
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
die(file_get_contents($file));
}
force_download($file
的问题是,用如Firefox浏览器,它的下载,但它是像“android.apk - 0字节”。所以它基本上不会下载文件的内容。
我会做什么错?这个解决方案?
重要事项:它必须在移动设备上工作。
);
确保file_get_contents($ file)可以读取文件,用任何头文件测试它 – RezaSh