0
用PHP我可以做拉鍊用下面的代碼PHP壓縮文件夾沒有循環
$zip = new ZipArchive;
if ($zip->open ('test.zip', ZipArchive::CREATE)) {
$zip->addFile('img1.jpg', 'user.jpg');
$zip->addFile('logo.jpg', 'file.jpg');
$zip->addFile('avatar.jpg', 'av.jpg');
//or we can even loop a directory
foreach(glob($dir . '/*') as $file)
{
//add each file from the directory
}
//end loop
$zip->close();
echo 'Zipped !';
} else {
echo 'failed';
}
?>
我的問題是,我們才能壓縮整個文件夾,而不構成環路,
$zip = new ZipArchive;
if ($zip->open ('test.zip', ZipArchive::CREATE)) {
$zip->addFolder('bla bla'); //like this,so that the entire files in it will be added
$zip->close();
echo 'Zipped !';
} else {
echo 'failed';
}
?>
我認爲你是對的人! – coolguy 2014-10-07 08:52:29