目录无法添加到zip存档

时间:2017-01-26 13:16:56

标签: php zip ziparchive

我想将一个目录(CLIENT_PATH)添加到现有的zip压缩文件,即wordpress.zip。其中的所有子目录和文件都应添加到我的zip存档的以下路径中:wp-content/themes/{new directory comes here}

当我运行以下脚本时,我将不会收到任何错误,但文件也不会添加到我的zip存档的主题目录中。

define('CLIENT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/wp_theme/clients_templates/' . $_POST['title']);
$zip = new ZipArchive;
$zip->open('wordpress.zip', ZipArchive::CREATE);
foreach (glob(CLIENT_PATH . "/*") as $file) {
    $zip->addFile($file, 'wordpress/wp-content/themes');
}
$zip->close();

我的代码出了什么问题?

0 个答案:

没有答案