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

PclZip让php轻松实现压缩与解压

WBOY
Release: 2016-06-13 11:34:45
Original
1368 people have browsed it

PclZip介绍
PclZip library能够压缩与解压缩Zip格式的压缩档(WinZip、PKZIP);且能对此类类档案进行处理,包括产生压缩档、列出压缩档的内容以及解压缩档案等等。由于能够在伺服器端进行压缩与解压缩的动作,所以相当方便使用。
PclZip定义一个PclZip类别,其类别物件可视为一个ZIP档案,亦提供method来进行处理。
 
 
PclZip官方地址:http://www.phpconcept.net/pclzip/index.php

实例代码
 
include_once('pclzip.lib.php');  //加载类文件
$filename=time().'bnxf.zip';//压缩后的文件名
$path='../../..'.$_GET['path'];//需要压缩的文件
$archive = new PclZip($filename);
$v_list = $archive->create($path,PCLZIP_OPT_REMOVE_ALL_PATH,PCLZIP_OPT_ADD_PATH,'bnxf'); //将压缩的文件目录改为bnxf
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}else{
echo"压缩成功";


}
?>

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