Windows上的Zip目录和Linux上的解压缩

时间:2017-12-16 11:11:31

标签: php linux windows ziparchive

我使用此代码在Windows中创建zip文件

text

enter image description here Zip文件是正确的...(上图)

现在我希望使用此代码

在Ubuntu中提取此文件
$plugin_address="D:/processmaker-3.2.1-x/apps/processmaker/htdocs/cakephp/plugins";
$rootPath = $plugin_address."/".$R;
$zipFileName = $rootPath.'.zip';
$zip = new ZipArchive();
$zip->open($zipFileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);

$files = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($rootPath),
    RecursiveIteratorIterator::LEAVES_ONLY
);

foreach ($files as $name => $file)
{

    if (!$file->isDir())
    {

        $filePath = $file->getRealPath();
        $relativePath = substr($filePath, strlen($rootPath) + 1);

        $filePath=str_replace("\\","/",$filePath);

        $zip->addFile($filePath, $relativePath);
    }
}


$zip->close();

此代码工作并解压缩zip文件,但不创建目录和子目录。 此代码在文件名中设置目录名!

(在Windows中提取代码是正确的,创建目录和子目录并在目录中设置文件) enter image description here

1 个答案:

答案 0 :(得分:2)

I use this function for zip on windows that worked extract on linux

socket.whatever((data , client) => {
     let temporaryValue = data.feed;
     //Problem is that this keeps getting               
     //updated as it's connected
}