Vipin Kumar Soni
Vipin Kumar Soni

Reputation: 834

Unable to read all files using "zip_read" from zip file

I have to traverse all files in a zip file that contains 65000 files approx. But it only able to read 315 files.

Unable to find the reason, no error in error log. I have used following code:

<?php
$zip = zip_open($newfile);
if ($zip) {
    $counter = 0;
    while ($zip_entry = zip_read($zip)) {
        $counter++;
        $filename = zip_entry_name($zip_entry);
        echo $counter . "-" . $filename . "<br/>";      
    }
    zip_close($zip);
}

Upvotes: 2

Views: 123

Answers (1)

Danny_ds
Danny_ds

Reputation: 11406

The number of files in a (regular) zip file is stored in an unsigned 16 bit integer. This means the maximum value is 65535.

Could it be that you have more than 65535 enties in that zip file, and that this integer overflows and only shows num_files - 65536, 315 in your case?

Upvotes: 1

Related Questions