//apk处理
public function getApk(){
//接收apk xml 文件
$xml = $_FILES;
$plist = $_FILES['upFile'];
$homeId = $_SESSION['homeId'];
$path = 'upload/'.$homeId.'/';
$newName = 'AndroidManifest.xml'; //文件名称
if(!file_exists($path)){
mkdir($path,0777,true);
}
$path = $path.$newName;
$res = move_uploaded_file($_FILES["upFile"]["tmp_name"],$path);
if($res){
$apkpath = 'upload/'.$homeId.'/'.time().'.apk';
$zip=new ZipArchive();
if($zip->open($apkpath, ZipArchive::OVERWRITE)=== TRUE){
$zip->addFile($path,$newName); //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法
}
//ApkParse 解析
require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/Apkparser.php");
//延时处理
}
$p= new \ApkParser();
$res= $p->open($apkpath);
$appName = $p->getAppName();
$version = $p ->getVersionCode();
$params["appName"] = $appName;
$params["version"] = $version;
$params["icon"] = 'iconimg';
if(!empty($appName)){
unlink($path);
unlink($apkpath);
}
return json_encode($params);
}
网友评论