我正在使用这个 PHP 类:http ://www.phpclasses.org/browse/file/9524.html
我使用此代码使其工作:
include('scripts/zip.php');
$directoryToZip = "./"; // This will zip all the file(s) in this present working directory
$outputDir = 'backup/'; //Replace "/" with the name of the desired output directory.
$zipName = 'backup_'.date('Y-m-d').'1.zip';
// If backup already exists, kill it
if(file_exists($outputDir.$zipName)){
unlink($outputDir.$zipName);
}
$createZipFile = new CreateZipFile;
/*
// Code to Zip a single file
$createZipFile->addDirectory($outputDir);
$fileContents=file_get_contents($fileToZip);
$createZipFile->addFile($fileContents, $outputDir.$fileToZip);
*/
//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);
$fd = fopen($outputDir.$zipName, "wb");
fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
现在如您所见,我告诉它使用此变量 .zip 压缩所有目录和文件:
$directoryToZip = "./";
我需要做一个例外:我不希望脚本对备份目录进行 .zip 压缩。
如何添加例外?