Mostafa Elkady
Mostafa Elkady

Reputation: 5791

how i can open a file in zip file without extract it by the PHP

i just want making a system that can open a file in a zip archive like i have archive.zip in this file.text i want make a class to makr this page zip.php?archiver=archive.zip&file=file.text i want this page show me the file.text contents any ideas?

Upvotes: 3

Views: 7971

Answers (2)

halfdan
halfdan

Reputation: 34214

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 wishes,
Fabian

Upvotes: 7

John Boker
John Boker

Reputation: 83709

you could probably do this:

http://www.php.net/manual/en/function.ziparchive-getfromname.php

it's a function in http://php.net/manual/en/book.zip.php

Upvotes: 1

Related Questions