I cannot create a zip file. It gives me this error. A search turned up no results. This is my function.
function CompressFile($fromExtractedFile)
{
$archive = new ZipArchive;
if ($archive->open($fromExtractedFile.".zip", ZipArchive::OVERWRITE | ZipArchive::CREATE) === TRUE) {
$archive->addFile($fromExtractedFile, 'payload.csv');
$archive->close();
}
else {
throw new Exception ("Compress operation to ZIP file failed. $fromExtractedFile -> $fromExtractedFile.zip");
}
return $fromExtractedFile.".zip";
}
Console:
Compressing /tmp/bing_PeUYiT
PHP Warning 'yii\base\ErrorException' with message 'ZipArchive::close(): Renaming temporary file failed: No such file or directory'
Docs: http://php.net/manual/en/book.zip.php
PHP 5.6, Win 8.1, Cygwin 2.5.2
Here is the same in PsySh:
>>> $archive = new ZipArchive
=> ZipArchive {#199
+"status": 0,
+"statusSys": 0,
+"numFiles": 0,
+"filename": "",
+"comment": "",
}
>>> $archive->open('/tmp/bing_PeUYiT.zip', ZipArchive::OVERWRITE|ZipArchive::CREATE)
=> true
>>> $archive->addFile('/tmp/bing_PeUYiT', 'payload.csv')
=> true
>>> $archive->close()
PHP warning: ZipArchive::close(): Renaming temporary file failed: No such file or directory on line 1