Introduction to PclZip
PclZip library can compress and decompress Zip format compressed files (WinZip, PKZIP); and can process such files, including generating compressed files, listing the contents of compressed files, and decompressing them. Compress files and more. Since compression and decompression can be performed on the server side, it is very convenient to use.
PclZip defines a PclZip category. Its category object can be regarded as a ZIP file and also provides methods for processing.
PclZip official address: http://www.phpconcept.net/pclzip/index.php
Example code
include_once('pclzip.lib.php'); //Load class files
$filename=time().'bnxf.zip';//Compressed file name
$path='../../..'.$_GET['path'];//Files that need to be compressed
$archive = new PclZip($filename);
$v_list = $archive->create($path,PCLZIP_OPT_REMOVE_ALL_PATH,PCLZIP_OPT_ADD_PATH,'bnxf'); //Change the compressed file directory to bnxf
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}else{
echo "Compression successful";
}
?>