用PHP下载APK应用程序

时间:2015-04-07 14:56:49

标签: php android

当我使用B4A Bridge或每根电缆传输应用程序时,每次运行都会完美无缺。

当我把它放在我的服务器上供测试人员下载时,下载成功,但后来我得到“解析错误:解析数据包时发生错误”。

这是我的PHP代码:

<?php
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="main.apk"');
header("Content-Length: 11111"); // size oif APK-file in byte
readfile('main.apk');
?> 

我也试过

<?php
header('Content-Type: application/vnd.android.package-archive');
header('Content-Disposition: attachment; filename="main.apk"');
$apk = file_get_contents('main.apk');
header("Content-Length: ".strlen($apk)); 
print($apk);
?>

Windows Server 2012 R2,IIS。

谢谢

彼得

2 个答案:

答案 0 :(得分:0)

您必须使用:

内容类型:application / jar

内容类型:application / apk

你的内容 - 长度&#34;使用filesize()函数。 filesize() php doc

答案 1 :(得分:0)

谢谢!

喜欢这个?结果相同。

header('Content-Type: application/jar');
header('Content-Type: application/apk');
header('Content-Disposition: attachment; filename="main.apk"');
header('Content-Length: ' . filesize ("main.apk"));
readfile('main.apk');
相关问题