I'm working on a function that displays recursively the list of files inside a zip file. A zip file inside another zip file could happen and I want to display its contents like a folder.
I have read carefully this question but I'm yet lost. Ideally It will be perfect if I could get the within zip with getStream
and send this stream to another ziparchive::open
, but I've not had much this way.
Things I have tried (just to test):
Try 1:
$data = file_get_contents('outer.zip');
$data64 = base64_encode($data);
$zip = new ZipArchive();
$r = $zip->open('data::text/plain;base64,'.$data64);
var_dump($r);
if($r){
$zip->close();
}
Try 2:
$zip = new ZipArchive();
$r = $zip->open('zip://outer.zip#inner.zip');
var_dump($r);
if($r){
$zip->close();
}
It will be so slow and bloated if I have to recursively decompress any file to temp just to list the files inside, especially with large files. At this point I'm seeking even shell_exec
solutions.