Open zip code and read contents

Possible duplicate:
mysql_fetch_array () expects parameter 1 to be a resource, boolean is set to select

I have a small php, application, or something else that opens a zip code and reads the contents. But it only works for some time ... sometimes, when I download .zip and try to view the contents, it works and echos returns me every file, but sometimes (yes, I have many .zip files), it returns these errors:

Warning: zip_read() expects parameter 1 to be resource, integer given in /home/blah/public_html/templates.php on line 23

Warning: zip_close() expects parameter 1 to be resource, integer given in /home/blah/public_html/templates.php on line 31

Here is my code:

$open = zip_open($file);
while($zip = zip_read($open)) {
$file = zip_entry_name($zip);
echo $file.'<br />';
}
zip_close($open);
+3
source share
2 answers

Cases where this occurs are cases where the Zip file does not open.

Zip_open() .

zip_read() zip_close() , .

$open , . , zip.

, .

+8
$open = zip_open($file);

if (is_numeric($open)) {
    echo "Zip Open Error #: $open";
   } else {
   while($zip = zip_read($open)) {
   .....
   }
+2

Source: https://habr.com/ru/post/1728380/


All Articles