通过网页链接直接下载APK

通过网页链接直接下载APK

方式一【PHP】

public function down()
{
     $filename = "存储路径/包名.apk";//必须给足权限下载
     header("application/vnd.android.package-archive");
     header('Content-Type: application/octet-stream'); 
     header("Content-Disposition: attachment; filename=".$filename);
     header("Content-length: " . filesize($filename));
     readfile($filename);
     die;
 }   
window.location.href =  "/down";

方式二

window.location.href =  "放包的域名/路径/包名.apk";

你可能感兴趣的:(PHP)