
PHP解压缩zip文件
1、使用PHP执行文件解压缩zip文件,前提条件,一定要确定服务器开启了zip拓展
2、封装的方法如下:
实例代码
open($filePath, ZipArchive::CREATE);
foreach ($files as $key => $file) {
//检查文件是否存在
if (!file_exists($file)) {
return false;
}
$zip->addFile($file, basename($file));
}
$zip->close();
return true;
}
function unzip($filePath, $path) {
if (empty($path) || empty($filePath)) {
return false;
}
$zip = new ZipArchive();
if ($zip->open($filePath) === true) {
$zip->extractTo($path);
$zip->close();
return true;
} else {
return false;
}
}
?>相关教程推荐:《PHP教程》
以上就是PHP如何解压缩zip文件?(代码示例)的详细内容,更多请关注考高分网其它相关文章!


