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");
}
}