Make a subdirectory inside the zip archive

This commit is contained in:
Chocobozzz 2016-09-01 12:55:32 +02:00
parent f765d25e20
commit 8012000247

View File

@ -30,7 +30,8 @@
$rootPath = realpath("./client-conf/$conf_dir"); $rootPath = realpath("./client-conf/$conf_dir");
// Initialize archive object // Initialize archive object
$archive_name = "openvpn-$conf_dir.zip"; $archive_base_name = "openvpn-$conf_dir";
$archive_name = "$archive_base_name.zip";
$archive_path = "./client-conf/$archive_name"; $archive_path = "./client-conf/$archive_name";
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE); $zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE);
@ -48,7 +49,7 @@
$relativePath = substr($filePath, strlen($rootPath) + 1); $relativePath = substr($filePath, strlen($rootPath) + 1);
// Add current file to archive // Add current file to archive
$zip->addFile($filePath, $relativePath); $zip->addFile($filePath, "$archive_base_name/$relativePath");
} }
} }