来自http://phpclasses.dev.skypp.com/browse/package/945.html
需要注册并通过邮件确认才能下载,不过.注册很简单,就填几个框子.
//用法示范
//利用archive打包
//包含这个类文件
require_once("zipArchive/archive.php");
$test = new zip_file( $zipFileName );
// Create archive in disk
$test->set_options(
array(
'basedir' => dirname($modpath),
'inmemory' => 0, //不在内存压缩.而是直接存放到磁盘.如果要压缩下载,则可以选择为1
'recurse' => 1,  //是否压缩子目录,resurse,递归的意思?
'storepaths' => 1, //是否存储目录结构,我选是。
'overwrite' => 1, //是否覆盖
'level' => 5 ,//压缩比
'name' => $zipFileName, //压缩最后生成的文件名,无需再次设置。这里是为了解说方便才放上来的。
'prepend' => "", //未知
'followlinks' => 0, //未知
'method' => 1, //未知
'sfx' => "", //不知道什么意思
'type' => "zip", //是zip还是tar...,无需设置,这里为了方便解说。放上来。
'comment' => ""
)
);
// Add files to archive,args can be array or a filename,and support *.*,but all files must be under the basedir
$files = array($module_name.".php",$module_name.".xml","templates/".$module_name.".html");
//可以将文件名单独列出来加进去,但是文件名必须在basedir下,文件名支持*.*表示压缩全部。
//$test->add_files($files); //加$files数组里的文件名

$test->add_files("diruti"); //加目录diruti,如果diruti是文件,那么就是加文件。
//$test->add_files(array("images/*.jp*g", "images/*.gif"));
// Store all exe files in bin without compression
//不压缩存储
//$test->store_files("bin/*.exe");
// 正式写入磁盘
$test->create_archive();
// Send archive to user for download
//如果是选择了在内存中创建,这里提供下载。
//$test->download_file();
Posted on 2005-12-16 21:40  古代  阅读(1979)  评论(4编辑  收藏  举报