下载
下载apk文件直接a链接即可,下面是用header下载文件,apk会显示HTML,乱码。。。
<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
$ff='huanbaoba.ipa';
header('application/iphone'); ios专属现在头文件
header('Content-Disposition:attachment;filename="huanbaoba.ipa"');
}else{
$ff='huanbaoba.apk';
header('application/vnd.android.package-archive');
header('Content-Disposition:attachment;filename="huanbaoba.apk"');
}
readfile($ff);
//获取设备类型
function get_device_type(){
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$type = 'other';
if(strpos($agent, 'iphone') || strpos($agent, 'ipad')){
$type = 'ios';
}
if(strpos($agent, 'android')){
$type = 'android';
}
return $type;
} 是不是微信端打开网页
一:js判断设备类型
function is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") { //判断是否在微信中打开此网页
return true;
} else {
return false;
}
} 二: php判断设备及浏览器等等类型
function is_weixin(){
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
return true;
}
return false;
}