Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In PHP is it possible to inspect content of a Zip file without extracting its content first?

Tags:

php

zip

I have seen the ZipArchive class in PHP which lets you read zip files. But I'm wondering if there is a way to iterate though its content without extracting the file first

like image 586
Roman Avatar asked Mar 22 '12 06:03

Roman


People also ask

Is it possible to see the contents of a ZIP file in the terminal without unzipping it Linux?

Using Vim. Vim command can also be used to view the contents of a ZIP archive without extracting it. It can work for both the archived files and folders. Along with ZIP, it can work with other extensions as well, such as tar.

How can I edit a ZIP file without extracting it?

open archive in archive manager. open text file in KDE gui editor. save text file and system ask you to refresh archive - click yes.

How do I browse the contents of a ZIP file?

Also, you can use the zip command with the -sf option to view the contents of the . zip file. Additionally, you can view the list of files in the . zip archive using the unzip command with the -l option.

Does a ZIP file need to be extracted?

In order to work with zipped files, they must be unzipped or extracted first. Windows has a built in program called Windows Compressed Folders which can do this for you.


1 Answers

As found as a comment on http://www.php.net/ziparchive:

The following code can be used to get a list of all the file names in a zip file.

<?php $za = new ZipArchive();   $za->open('theZip.zip');   for( $i = 0; $i < $za->numFiles; $i++ ){      $stat = $za->statIndex( $i );      print_r( basename( $stat['name'] ) . PHP_EOL );  } ?> 
like image 61
deceze Avatar answered Sep 20 '22 19:09

deceze