简体   繁体   中英

ZipArchive in PHP7 cannot find content of zip

I have a PHP script to unzip a zip file from a form, but whatever content i put in the zip, the opened zip cannot find the items. When I var_dump() my zip I get this:

object(ZipArchive)#800 (5) {
    ["status"]=> int(0) ["statusSys"]=> int(0) 
    ["numFiles"]=> int(0) 
    ["filename"]=> string(14) "/tmp/php83KJHe" 
    ["comment"]=> string(0) ""
} 

here is the script:

$zip     = new  \ZipArchive();
$zipname     = $_FILES[ 'lezip' ][ 'tmp_name' ];
$zip->open( $zipname, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE );
var_dump( $zip );
$zipsuccess = $zip->extractTo( $destination );
var_dump( ' success: ' . $zipsuccess );

the success dump says it is ok

string(11) " success: 1" 

And i did set up the $destination folder, it exists and have write access.

Why can't ZipArchive find any items to the zips i upload ?

From PHP docs on ZipArchive::OVERWRITE :

Always start a new archive, this mode will overwrite the file if it already exists.

You can't use this flag if you wish to read an existing archive.

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