Home  >  Article  >  Backend Development  >  php自定义apk安装包范例

php自定义apk安装包范例

WBOY
WBOYOriginal
2016-06-13 12:18:211205browse

php自定义apk安装包实例

本文实例讲述了php自定义apk安装包的方法,分享给大家供大家参考。具体实现方法如下:

<?php // 源文件$apk    = "gb.apk";// 生成临时文件$file   = tempnam("tmp", "zip");// 复制文件if(false===file_put_contents($file, file_get_contents($apk))){    exit(&#39;copy faild!&#39;);}// 打开临时文件$zip    = new ZipArchive();$zip->open($file);// 添加文件// 由于apk限定只能修改此目录内的文件,否则会报无效apk包$zip->addFromString('META-INF/extends.json', json_encode(array('author'=>'deeka')));// 关闭zip$zip->close();// 下载文件header("Content-Type: application/zip");header("Content-Length: " . filesize($file));header("Content-Disposition: attachment; filename=\"{$apk}\"");// 输出二进制流readfile($file);// 删除临时文件unlink($file);?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn