Pclzip 使用入门
PclZip::PclZip() :
Class creator #实例化类
PclZip::create() :
Create the PKZIP file and add files or folders #创建压缩文件
PclZip::listContent() :
List content of an archive #获取压缩文件内容列表
PclZip::extract() :
Extract all or part of the content of the archive #解压文件/部分文件
PclZip::properties() :
Get properties of the archive #获取压缩文件信息
PclZip::add() :
Get properties of the archive #向压缩文件内添加内容(官网写错了)
PclZip::delete() :
Delete files inside the archive #删除压缩文件内文件
PclZip::merge() :
Add one archive content in a second archive #合并压缩文件
PclZip::duplicate() :
Duplicate the archive #复制压缩文件
实例一,创建压缩文件:
include_once(‘pclzip.lib.php‘);
$archive = new PclZip(‘archive.zip‘);
$v_list = $archive->create(‘file.txt,data/text.txt,folder‘);
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
实例二,解压文件:
require_once(‘pclzip.lib.php‘);
$archive = new PclZip(‘archive.zip‘);
if ($archive->extract() == 0) {
die("Error : ".$archive->errorInfo(true));
}
实例三,解压部分文件:
require_once(‘pclzip.lib.php‘);
$archive = new PclZip(‘archive.zip‘);
if ($archive->extract(PCLZIP_OPT_BY_NAME, $fiel_list) == 0) {
die("Error : ".$archive->errorInfo(true));
}
实例四,获取压缩文件列表:
include_once(‘pclzip.lib.php‘);
$zip = new PclZip("test.zip");
if (($list = $zip->listContent()) == 0) {
die("Error : ".$zip->errorInfo(true));
}
for ($i=0; $i<sizeof($list); $i++) {
for(reset($list[$i]); $key = key($list[$i]); next($list[$i])) {
echo "File $i / [$key] = ".$list[$i][$key]."";
}
echo "";
Pclzip 使用入门
原文:http://blog.csdn.net/qlong_dd/article/details/44201545