利用Pear类库的Archive_Zip类可以很方便的完成文件的压缩,例子如下:
include ('Archive/Zip.php'); // imports
$obj = new Archive_Zip('test.zip'); // name of zip file
$files = array('picsour/1-txt-1.psd',
'picsour/txt-6.psd',
'picsour/txt-6-1.psd'); // files to store
if ($obj->create($files)) {
echo 'Created successfully!';
} else {
echo 'Error in file creation';
}
$files = $obj->listContent(); // array of file information
foreach ($files as $f) {
foreach ($f as $k => $v) {
echo "$k: $v\n" ."
";
}
echo "\n";
}
阅读(980) | 评论(0) | 转发(0) |