简体   繁体   中英

Ziparchive unable to open zip file only in PHP

I'm trying to unzip a file using PHP ZipArchive class but when I try:

$file = '/path/to/zip/file.zip';
$zip = new ZipArchive();
$res = $zip->open($file, ZipArchive::CHECKCONS);

The result is ZipArchive::ER_INCONS (Zip archive inconsistent)

Now, I've been able to open the zip file on my desktop (Windows 7) as well as using the bash command line tool unzip on the same box where the PHP application is running (Ubuntu 12.04). I am even able to unzip the file with in PHP using exec('unzip', $file); .

I have checked permissions for the cache folder and the zip file and the webserver has both read and write permission. I am able to open other zip file in the same directory with PHP's ZipArchive class.

I'm not sure if it is relevant, but the zip file I'm trying to open contains two zip files.

Any ideas as to why this may be happening?

原来这个文件被上传为ASCII,我把它改成上传为二进制文件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM