您好,欢迎访问一九零五行业门户网

php压缩与解压缩类PclZip的例子

create($_server['document_root'] ,pclzip_opt_remove_path,$_server['document_root']);if($v_list == 0){ echo '异常:'.$z->errorinfo(true); }else { echo '备份成功'; }?>
复制代码
其它用法举例:
extract(pclzip_opt_path, extract/folder/);//增加这个目录在压缩档中,完成以后压缩档里面会有backup这个目录,backup里面会有这两个档案
$list = $archive->create(file.txt,image.gif,pclzip_opt_add_path, backup);//去掉部份的路径,这里完成后会变成test/file.txt
$list = $archive->add(/usr/local/user/test/file.txt,pclzip_opt_remove_path,/usr/local/user);//把所有路径都去掉,这个压缩档建立完后,里面就只会有file.txt跟image.gif,不会有目录了
$list = $archive->create(data/file.txt images/image.gif,pclzip_opt_remove_all_path);//把解压缩出来的档案的chmod设成0777
$list = $archive->extract(pclzip_opt_set_chmod, 0777);//解压缩部份的档案,这个参数是使用档案名称判别
//引数可以用下面这样的阵列$rule_list[0] = 'test/aaa.txt';$rule_list[1] = 'test/ddd.txt';//或是下面这样,一个字串中,用逗号分隔每个要解压缩的档案$rule_list = test/aaa.txt,test/ddd.txt;$list = $archive->extract(pclzip_opt_by_name,$rule_list);//解压缩部份的档案,使用php的ereg()函式,档案名称有比对成功的都会被解压缩
$list = $archive->extract(pclzip_opt_by_ereg, aa);//解压缩部份的档案,使用php的preg_match()函式,档案名称有比对成功的都会被解压缩
$list = $archive->extract(pclzip_opt_by_preg, /^bb/);//上面这两个函式如果不懂的话,请先研究正规表示法(regular expression)//依照阵列中元素的索引解压缩,可是我不太懂index啥 = =a
$list = $archive->extract(pclzip_opt_by_index, array('0-1','6-7'));//将一个档案内容解压缩成一个字串
$list = $archive->extract(pclzip_opt_by_name, data/readme.txt,pclzip_opt_extract_as_string);//将一个档案内容解压缩完后直接输出(echo)
$list = $archive->extract(pclzip_opt_by_name, data/readme.txt,pclzip_opt_extract_in_output);//将一个档案加入一个压缩档中,但不会对此档案压缩
$list = $archive->add(data/file.txt, pclzip_opt_no_compression);//对此压缩档增加一个注解,如果原本就有注解的话会被覆盖掉
$list = $archive->create(data, pclzip_opt_comment, add a comment);//对此压缩档增加一个注解,如果原本就有注解的话会接在后面
$list = $archive->add(data, pclzip_opt_add_comment, add a comment afterthe existing one);//对此压缩档增加一个注解,如果原本就有注解的话会放在原本的注解前面
$list = $archive->add(data, pclzip_opt_prepend_comment, add a comment beforethe existing one);?>
复制代码
其它类似信息

推荐信息