Getting started with Pclzip
pclzip::P clzip (): 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 #解压文件/partial files
pclzip::p roperties (): Get Properties of the archive #获取压缩文件信息
Pclzip::add (): Get Properties of the archive #向压缩文件内添加内容 (incorrectly written on the website)
pclzip::d elete (): Delete files inside the archive #删除压缩文件内文件
Pclzip::merge (): ADD One archive content in a second archive #合并压缩文件
pclzip::d uplicate (): Duplicate The archive #复制压缩文件
Instance one, create the compressed file:
include_once (' pclzip.lib.php ');
$archive= newPclzip(' Archive.zip ');
$v _list= $archive -Create(' File.txt,data/text.txt,folder ');
if ($v _list== 0) {
Die ("Error:".$archive -errorinfo(true));
}
Example two, unzip the file:
require_once (' pclzip.lib.php ');
$archive= newPclzip(' Archive.zip ');
if ($archive -Extract() == 0) {
Die ("Error:".$archive -errorinfo(true));
}
Example three, unzip some files:
require_once (' pclzip.lib.php ');
$archive= newPclzip(' Archive.zip ');
if ($archive -Extract(Pclzip_opt_by_name, $fiel _list) = =0) {
Die ("Error:".$archive -errorinfo(true));
}
Example four, get a list of compressed files:
include_once (' pclzip.lib.php ');
$zip= newPclzip("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 ""; }
Reference: HTTP://WWW.PHPCONCEPT.NET/PCLZIP/USER-GUIDE/21
Getting Started with Pclzip