zip use example of pclzip decompression class php

  • 2021-01-25 07:21:03
  • OfStack

PclZip profile
PclZip is a powerful PHP class that compresses and decompresses zip files. PclZip can compress and decompress Zip files (WinZip, PKZIP). PclZip is a class that compresses and decompresses zip files. It can also process such files, including generating compressed files, listing the contents of compressed files and unzipping files.

Simple, easy to use and powerful are my comments on it.

I recently developed my Wordpress plugin, ShareLink. During this process, I found the PclZip class that operates on the zip file, and I have to recommend it.

One more reason to recommend it is that I found a lewd use of an PHP function parameter in its source code. An example is given below.

Generate zip files
Use 1:


< ?php
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));
}
?>

Use 2:


< ?php
include_once('pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->create('data/file.txt,data/text.txt',
PCLZIP_OPT_REMOVE_PATH,'data',
PCLZIP_OPT_ADD_PATH,'install');
if($v_list==0){
die("Error:".$archive->errorInfo(true));
}
?>


Related articles: