我的代码下载apk文件在台式电脑,但不能在移动设备。我的代码是:
<?php
$file_path="www.XXXXXXX/blood/XXXXXX.apk";
$file_name="Blood.apk";
header('Content-Type: application/vnd.android.package-archive');
header("Content-length: " . filesize($file_path));
header('Content-Disposition: attachment; filename="' . $file_name . '"');
ob_end_flush();
readfile($file_path);
return true;
?>
正如在标签javascript
中提到的,我创建了这个小代码
<div id="i"></div>
<button onclick="b()">DOWNLOAD!</button>
<script>
function b(){
var j = document.createElement("iframe");
j.src = "a.apk";
j.style.display="none";
document.getElementById('i').appendChild(j);
}
</script>
在三星Galaxy S2中测试在浏览器和Chrome中都工作得很好!