github项目
1、Linux 安装zlib库
XML
cd /usr/local/src
wget https://zlib.net/current/zlib.tar.gz
tar -zxvf zlib.tar.gz
cd zlib-1.3
./configure
make && make install
2、zlib的使用
php
$all_name = 'all.zip';
// 创建ZipArchive对象
$zip_all = new ZipArchive();
if ($zip_all->open('all.zip', ZipArchive::CREATE) === TRUE) {
$zip_all->addFile(dirname(dirname(__FILE__)) .'666.docx', '666.docx');
// 关闭Zip文件
$zip_all->close();
}
//下载Zip文件到本地
header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=' . $all_name . '');
header('Content-Length: ' . filesize($all_name));
readfile($all_name);
unlink($all_name);
exit;