文件位于:/include/zip.class.php
以下是示例,使用时将示例代码放根站点根目录,非根目录的自行修改 include 行包含 zip.class.php 的代码。
压缩某个目录:
<?php
set_time_limit(0);
include('include/zip.class.php');
$zip = new zip();
$file = time().'.zip';
$zip->CompileZipFile('templets/default', $file,$ftype='dir');
echo '<a href="'.$file.'">'.$file.'</a>';
// 第6行的 templets/default 是即将压缩的目录,压缩整站,将 templets/default 换成 . (一个英文句点,不是 ./)
?>
压缩某个文件:
<?php
set_time_limit(0);
include('include/zip.class.php');
$zip = new zip();
$file = time().'.zip';
$zip->CompileZipFile('plus/car.php', $file,$ftype='dir');
echo '<a href="'.$file.'">'.$file.'</a>';
// 第6行的 plus/car.php 是即将压缩的文件名
?>
解压文件:
<?php
set_time_limit(0);
include('include/zip.class.php');
$zip = new zip();
$file = time().'.zip';
$zip->ExtractAll('www.zip', './');
echo 'done.';
// www.zip 是需要解压的文件,./ 代表解压到当前目录,你可以写 wwwroot、./wwwroot
?>
<完>