Home > php教程 > php手册 > body text

php实现zip文件解压操作,

WBOY
Release: 2016-06-13 08:51:48
Original
944 people have browsed it

php实现zip文件解压操作,

PHP解压zip文件函数,源码简短,需要使用 ZZIPlib library 扩展,使用前请确认该扩展已经开启。

<&#63; 
/**********************
*@file - path to zip file 需要解压的文件的路径
*@destination - destination directory for unzipped files 解压之后存放的路径
*@需要使用 ZZIPlib library ,请确认该扩展已经开启
*/ 
function unzip_file($file, $destination){ 
// 实例化对象 
$zip = new ZipArchive() ; 
//打开zip文档,如果打开失败返回提示信息 
if ($zip->open($file) !== TRUE) { 
  die ("Could not open archive"); 
} 
//将压缩文件解压到指定的目录下 
$zip->extractTo($destination); 
//关闭zip文档 
$zip->close(); 
  echo 'Archive extracted to directory'; 
} 
//测试执行 
//unzip_file("func.zip","jieya"); 
&#63;>
Copy after login

这就是php解压zip文件的函数代码,希望对大家的学习有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!