diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index ce4d22533e..2ccb992741 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -297,7 +297,12 @@ public function pclzipAddFromString($localname, $contents) $pathRemoved = $this->tempDir; $pathAdded = $filenameParts['dirname']; - $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); + if ( ! $this->usePclzip) { + $pathAdded = $pathAdded.'/'.ltrim(str_replace('\\', '/', substr($filename, strlen($pathRemoved))), '/'); + $res = $zip->addFromString($pathAdded, $contents); + } else { + $res = $zip->add($filename, PCLZIP_OPT_REMOVE_PATH, $pathRemoved, PCLZIP_OPT_ADD_PATH, $pathAdded); + } // Remove temp file @unlink($this->tempDir . DIRECTORY_SEPARATOR . $filenameParts['basename']);