我发现了这个很棒的课程,除了...我指定了输出目录,一切都很好,如下所示:
$outputDir = "/backup/";
但它不会在那里输出 zip,它会在站点根目录上输出它。
这是该课程的链接,您可以查看它:)
http://www.phpclasses.org/browse/file/9525.html
我很感激任何帮助!
这是我调用类的整个代码:
include('scripts/zip.php');
$fileToZip = "License.txt";
$fileToZip1 = "CreateZipFileMac.inc.php";
$fileToZip2 = "CreateZipFile.inc.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 = "test.zip";
$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($zipName, "wb");
fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);