Cannot create zip archive in PHP, always returns ZIPARCHIVE::ER_MULTIDISK
$fileName=$_SERVER['DOCUMENT_ROOT'].'/temp/temp.zip';
$zip = new ZipArchive();
$err=$zip->open($fileName,ZipArchive::CREATE);
$zipFileFunctionsErrors = array(0=>'OK',
ZIPARCHIVE::ER_MULTIDISK => 'Multi-disk zip archives not supported.',
...,
...
);
echo $zipFileFunctionsErrors[$err];
$zip->addFromString('empty.txt', '');
$zip->close();
Outputs
Multi-disk zip archives not supported
zip file didn't created
on local machine code works good
I think that your issue has to be something with the php version, sounds like it's this: (from php.net comments):
Some older PHP versions used to return false if zip_open failed, and newer versions return the number of error (as integer), so instead of this:
$zip = zip_open($zip_file);
if ($zip) {
// consider zip file opened successfully
}
use this:
$zip = zip_open($zip_file);
if (is_resource($zip)) {
// consider zip file opened successfully
}
Sounds like you are getting the first non numeric index from the array, maybe '1' as 'true' and that's why it's displaying the element '1' on your errors array
First, check if you can create files with php on server side. There may be an identity problem. php may operate on i.e: apache id and your id is yourFtpId..
Then check if zip library is supported with php on the server, phpinfo can show that.
Then check if your server configuration allows zip commands from php.
When these diagnostics are over, if you find a problem with these, you should address the server admin to solve them.
来源:https://stackoverflow.com/questions/15381142/ziparchive-open-error-in-php