$fileToZip="License.txt";
$fileToZip1="CreateZipFileMac.inc.php";
$fileToZip2="CreateZipFile.inc.php";
$directoryToZip="../images"; // This will zip all the file(s) in this present working directory
$outputDir="/"; //Replace "/" with the name of the desired output directory.
$zipName="test.zip";
include_once("CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;
//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);
$rand=md5(microtime().rand(0,999999));
$zipName=$rand."_".$zipName;
$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
$createZipFile->forceDownload($zipName);
@unlink($zipName); `
Когда я запускаю этот код, он создает zip-файл test.zip
, но когда я распаковываю его, я получаю все файлы в папке images
, и я не хочу, чтобы это произошло.Я просто хочу получить все файлы, а не в папке, при распаковке.Как я могу изменить этот код для достижения этого?Есть ли другой способ сделать это?Спасибо.