问题描述
我希望用户从我的网站下载一个应用程序并将其安装在他们的设备上。 用户具有授权码,并在提交表单后开始下载。
if($_SERVER["REQUEST_METHOD"] == "POST"){
if($download_allow){
header("Cache-Control: public");
header("Content-description: File Transfer");
$contenttype = "application/com.android.package-install";
header("Content-Type: " . $contenttype);
header("Content-disposition: attachment; filename=\"".FILENAME."\"");
header("Content-Tranfer-Encoding: binary");
readfile(FILE_PATH);
}
}
如果我使用链接:
<a href="myfolder/apk/release.apk" type="application/vnd.android.package-archive">Download MyApp</a>
完全没有问题。我可以下载并安装apk。 我不想使用链接,因为我想使用一次性授权码。
好的...我用以下代码完成了
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.android.package-archive');
header('Content-disposition: attachment; filename='.basename(FILENAME));
header('Content-transfer-encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize(FILE_PATH));
header('Location:'.FILE_PATH);
这在HTACCESS中
AddType application/octet-stream .apk
AddType application/vnd.android.package-archive .apk
ForceType application/octet-stream
但是现在我的问题是: 这样安全吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)