How can I open a file in a zip file without extracting it from PHP

I just want to create a system that can open a file in a zip archive as I have archive.zip in this .text file I want to make a class for makr this page? Zip.php archiver = archive.zip & file = file.text I want this page to show me the contents of file.text any ideas?

+3
source share
2 answers

From the PHP manual: ZipArchive :: getFromName () . This is exactly what you need.

<?php
$z = new ZipArchive();
if ($z->open(dirname(__FILE__) . '/test_im.zip')) {
    $string = $z->getFromName("mytext.txt");
    echo $string;
}
?>

Best regards,
Fabian

+6
source

Source: https://habr.com/ru/post/1725067/


All Articles