简体   繁体   English

PHP Windows中的递归Zip目录?

[英]Recursive Zip directory in PHP Windows?

I'm using this code to zip a folder 我正在使用此代码压缩文件夹

 D:\VIRTUAL\consuladoperurio.com.br\WWW\siscons\test\wordtemplatedownload\pasta 

into test.zip. 进入test.zip。 The folder "pasta" has the follow tree 文件夹“ pasta”具有以下树

pasta
    subfolder
        styles.xml

When I run the code 当我运行代码

$wordtemplatedownloadpath ="D:\\VIRTUAL\\consuladoperurio.com.br\\WWW\\siscons\\test\\wordtemplatedownload\\"
Zip($wordtemplatedownloadpath."pasta", $wordtemplatedownloadpath."test.zip");

and then extract test.zip I get the folder and file 然后解压test.zip我得到了文件夹和文件

在此处输入图片说明 respectively. 分别。 When I need the first tree. 当我需要第一棵树时。

I'm trying to replace '/' to '\\' but don't work. 我正在尝试将'/'替换为'\\',但是不起作用。 How I will be able to solve that? 我将如何解决呢?

I will concentrate on your last question "I'm trying to replace '/' to '\\' but don't work. How I will be able to solve that?" 我将集中讨论您的最后一个问题:“我试图将'/'替换为'\\',但不起作用。我将如何解决该问题?” as at the moment it is unclear what you are asking about. 目前尚不清楚您在问什么。

But if you are having problems specifying a path to your directory try to use the constant DIRECTORY_SEPARATOR within your path definition 但是,如果在指定目录路径时遇到问题,请尝试在路径定义中使用常量DIRECTORY_SEPARATOR

Example

$wordtemplatedownloadpath ="D:" . $ wordtemplatedownloadpath =“ D:”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "VIRTUAL" . “虚拟”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "consuladoperurio.com.br" . “ consuladoperurio.com.br”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "WWW" . “ WWW”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "siscons" . “ siscons”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "test" . “测试”。 DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR。 "wordtemplatedownload" . “ wordtemplatedownload”。 DIRECTORY_SEPARATOR ; DIRECTORY_SEPARATOR;

Please let me know if this fixes your problem 请让我知道是否可以解决您的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM