私はこの素晴らしいクラスを見つけました、それを除いてすべてうまくいきます...私は次のように出力ディレクトリを特定します:
$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);