|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-21 14:30 UTC] dafish at soundtrack-board dot de
Description:
------------
I'm trying to open a zip file in mode OVERWRITE. I always end up getting error
code 1,
Test script:
---------------
$this->archiveName = TEMP_DIR . '/archive_' . $this->tid . '_' . date('Ymd') . '.zip';
$errorCode = $this->zipArchive->open($this->archiveName, ZipArchive::CREATE);
if ((integer)$errorCode > 0)
{
throw new RuntimeException('Unable to open archive ' . $this->archiveName . ' (Error: ' . $errorCode . ')');
}
if (empty($this->files))
{
throw new RuntimeException('No files available to be added to the archive.');
}
foreach ($this->files as $filename => $filepath)
{
$this->zipArchive->addFile($filepath, $filename);
}
if (!$this->zipArchive->close())
{
throw new RuntimeException('An error occured while trying to write the archive.');
}
return $this->archiveName;
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 20:00:01 2025 UTC |
Here is a little self contained script producing the same error: $zip = new ZipArchive(); $archiveName = 'testtest.zip'; $error = $zip->open($archiveName, ZipArchive::OVERWRITE); echo $error . PHP_EOL; // outputs '1' $zip->addFromString('text.txt', 'Lorem Ipsum'); $zip->close();