Код: Выделить всё
-- file1
-- file2
-- directory/file3 --> ../file1
Код: Выделить всё
$zip = new ZipArchive();
$zip->open($zipFile, ZipArchive::CREATE | ZipArchive::OVERWRITE)
foreach($filesToZip as $name => $file) {
if (!$file->isDir()) {
$filePath = $file->getPathname();
$relativePath = substr($filePath, strlen($rootPath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
Я также пробовал использовать file->getRealPath(), что только усугубляет проблему, поскольку он добавляет файл с его абсолютным путем в архив.
Подробнее здесь: https://stackoverflow.com/questions/791 ... ziparchive