Ty Kayn
Ty Kayn

Reputation: 799

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 ?

Upvotes: 0

Views: 372

Answers (1)

Shira
Shira

Reputation: 6560

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.

Upvotes: 1

Related Questions