2

I'd like to list the root content of the zip archive to detect if there's only one directory there so that I could extract just the content of this directory without itself - just in case someone uploads a file made by simple "add to archive".

For instance if I get a file containing:

directory
|- fileA
|- fileB

I want to extract just fileA and fileB but if I receive a file with multiple dirs/files in the main node I want to keep the structure. Is there an easy way to do so? Please, keep in mind I need just the root directory and simple iteration gives the list of all files.

Tomasz Kapłoński
  • 1,320
  • 4
  • 24
  • 49
  • 3
    possible duplicate of [In PHP is it possible to inspect content of a Zip file without extracting its content first?](http://stackoverflow.com/questions/9817525/in-php-is-it-possible-to-inspect-content-of-a-zip-file-without-extracting-its-co) – sanchez Aug 24 '15 at 11:41
  • 1
    The post you linked shows how to list all the files/dirs in the file and I need only the ones from the root directory... – Tomasz Kapłoński Aug 24 '15 at 11:51
  • 1
    @Moby04, with the *full* list of entries, you should be able to filter the ones you need or don't need. – lxg Aug 24 '15 at 12:13

0 Answers0