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