0

I'm trying to write a php script that woud echo filenames of zipped files in folder. Every archive conains one file. For example i have on server:

file1.zip containing zipped file with name file1.exe
file2.zip containing zipped file with name file1.txt
folder1/file3.zip containing zipped file with name file1.html

i'd like the script to echo a list of:

file1.exe
file1.txt
folder1/file1.html

Is it even possible in PHP ? how do i approach such problem?

Here is the script i use to get filenames with foldernames on server (if also gives file modification date and size) What is does not give me is filename of file that zip file contains:

// Create recursive dir iterator which skips dot folders
$dir = new RecursiveDirectoryIterator('./patchfolder',
FilesystemIterator::SKIP_DOTS);

// Flatten the recursive iterator, folders come before their files
$it  = new RecursiveIteratorIterator($dir,
RecursiveIteratorIterator::SELF_FIRST);
// Maximum depth is 1 level deeper than the base folder
$it->setMaxDepth(1);

// Basic loop displaying different messages based on file or folder
foreach ($it as $fileinfo) {
if ($fileinfo->isFile()) {
echo str_replace("./patchfolder/","",$fileinfo.",". date ("Y-m-d H:i:s",filemtime($fileinfo)).",".filesize($fileinfo)."\n");
}
}
Greg Viv
  • 817
  • 1
  • 8
  • 22
  • 1
    You probably want to use ZipArchive - there's a very similar question at http://stackoverflow.com/questions/9817525/in-php-is-it-possible-to-inspect-content-of-a-zip-file-without-extracting-its-co – Joe Pietroni Apr 26 '14 at 16:05
  • you can use this as reference. [link](http://stackoverflow.com/questions/10420112/how-to-read-a-single-file-inside-a-zip-archive) – user1978142 Apr 26 '14 at 16:11

0 Answers0