<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
$ff='huanbaoba.ipa';
header('application/iphone');
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;
}
安卓已经测试通过了
ios未测试
<?php
header("Content-Type:text/html; charset=utf-8");
if(get_device_type()=='ios'){
$ff='huanbaoba.ipa';
header('application/iphone');
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;
}
安卓已经测试通过了
ios未测试