Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : Zip File Functions : ZipArchive::getStream

ZipArchive::getStream

Get a file handler to the entry defined by its name (read only). ()
resource ZipArchive::getStream ( string name )

Example 2706. Get the entry contents with fread and store it.

<?php
$content
= '';
$z = new ZipArchive();
if (
$z->open('test.zip')) {
   
$fp = $z->getStream('test');
   if(!
$fp) exit("failed\n");

   while (!
feof($fp)) {
       
$contents .= fread($fp, 2);
   }

   
fclose($fp);
   
file_put_contents('t',$contents);
   echo
"done.\n";
}
?>

Example 2707. Same as the previous example but with fopen and the zip stream wrapper

<?php
$fp
= fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
if (!
$fp) {
   exit(
"cannot open\n");
}
while (!
feof($fp)) {
   
$contents .= fread($fp, 2);
   echo
"$contents\n";
}
fclose($fp);
echo
"done.\n";
?>

Example 2708. Stream wrapper and image, can be used with the xml function as well

<?php
$im
= imagecreatefromgif('zip://' . dirname(__FILE__) . '/test_im.zip#pear_item.gif');
imagepng($im, 'a.png');
?>

Change Language


Follow Navioo On Twitter
zip_close
zip_entry_close
zip_entry_compressedsize
zip_entry_compressionmethod
zip_entry_filesize
zip_entry_name
zip_entry_open
zip_entry_read
zip_open
zip_read
ZipArchive::addEmptyDir
ZipArchive::addFile
ZipArchive::addFromString
ZipArchive::close
ZipArchive::deleteIndex
ZipArchive::deleteName
ZipArchive::extractTo
ZipArchive::getArchiveComment
ZipArchive::getCommentIndex
ZipArchive::getCommentName
ZipArchive::getFromIndex
ZipArchive::getFromName
ZipArchive::getNameIndex
ZipArchive::getStream
ZipArchive::locateName
ZipArchive::open
ZipArchive::renameIndex
ZipArchive::renameName
ZipArchive::setArchiveComment
ZipArchive::setCommentIndex
ZipArchive::setCommentName
ZipArchive::statIndex
ZipArchive::statName
ZipArchive::unchangeAll
ZipArchive::unchangeArchive
ZipArchive::unchangeIndex
ZipArchive::unchangeName
eXTReMe Tracker