[php]压缩类(archive,支持TAR/GZIP/BZIP2/ZIP),使用方便,一个文件
2005-12-16 21:40
591 查看
来自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();
需要注册并通过邮件确认才能下载,不过.注册很简单,就填几个框子.
//用法示范
//利用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();
相关文章推荐
- Guardio全能优化3.4.0.420:木马/间谍专杀,支持Zip/GZip/Tar/Cab/Rar等压缩格式文件,全面杀除超过30,000种木马
- [置顶] 使用Python3解压gz、tar、tgz、zip、rar五种格式的压缩文件例子
- 使用PHP和GZip压缩网站JS/CSS文件加速网站访问速度
- php使用gzip压缩传输js和css文件的方法
- 【Delphi】从内存读取或解压压缩文件(RAR、ZIP、TAR、GZIP等)(三)
- 使用PHP和GZip压缩网站JS/CSS文件加速网站访问速度
- 使用tar和gzip对某文件夹内的某类型文件进行压缩与解压缩
- 指令篇:文件与文件系统的压缩与解压与打包(归档)与解压___gzip、zcat;bzip2、bzcat;zip; tar
- 使用PHP对文件进行压缩解压(zip)
- Linux系统文件的网络传输、归档tar、压缩zip、gzip、bzip2、xz、gz、bz2
- 使用php判断服务器是否支持Gzip压缩功能
- php处理zip压缩文件,PHP自带ZIP压缩、解压缩类ZipArchiv介绍及使用
- AIX 文件 打包 与 压缩 tar gzip compress 的使用
- php生成zip压缩文件的方法,支持文件和压缩包路径查找
- 使用Python3解压gz、tar、tgz、zip、rar五种格式的压缩文件例子
- python脚本编程:使用zip或者tar压缩和解压文件
- 把一个文件夹下的文件先打包成一个tar文件,然后再用gzip压缩。
- php使用gzip压缩传输js和css文件的方法
- 【Delphi】从内存读取或解压压缩文件(RAR、ZIP、TAR、GZIP等)(一)
- php使用gzip压缩传输js和css文件的方法