From 8012000247869cd47df53d195aca943e00ec0375 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 1 Sep 2016 12:55:32 +0200 Subject: [PATCH] Make a subdirectory inside the zip archive --- index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 146d474..17e4820 100644 --- a/index.php +++ b/index.php @@ -30,7 +30,8 @@ $rootPath = realpath("./client-conf/$conf_dir"); // 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"; $zip = new ZipArchive(); $zip->open($archive_path, ZipArchive::CREATE | ZipArchive::OVERWRITE); @@ -48,7 +49,7 @@ $relativePath = substr($filePath, strlen($rootPath) + 1); // Add current file to archive - $zip->addFile($filePath, $relativePath); + $zip->addFile($filePath, "$archive_base_name/$relativePath"); } }