My users upload zip files through FTP, then a php file adds them to a RSS file.
I'm trying to find a way to check each ZIP files to validate the file and check if it is broken or if the upload is unfinished. Is there a way to do that ?
The result from open
can be also be true
, which should be evaluated first. Without the check ZipArchive:ER_NOZIP
, which equals (int) 1, will always match.
$zip = new ZipArchive();
$res = $zip->open('test.zip', ZipArchive::CHECKCONS);
if ($res !== TRUE) {
switch($res) {
case ZipArchive::ER_NOZIP:
die('not a zip archive');
case ZipArchive::ER_INCONS :
die('consistency check failed');
case ZipArchive::ER_CRC :
die('checksum failed');
default:
die('error ' . $res);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With