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



PHP : Function Reference : Zip File Functions : zip_read

zip_read

Read next entry in a ZIP file archive (PHP 4 >= 4.0.7, PHP 5 >= 5.2.0, PECL zip:1.0-1.9.0)
mixed zip_read ( resource zip )


Code Examples / Notes » zip_read

nico

If you get an error like this:
Warning: zip_read() expects parameter 1 to be resource, integer given in xxxxxx on line x
It's because zip_open() failed to open the file and returned an error code instead of a resource. It took me a while to figure out why it failed to open the file, until I tried to use the FULL path to the file.
<?php
// Even if the file exists, zip_open() will return an error code.
$file = 'file.zip';
$zip = zip_open($file);
// The workaround:
$file = getcwd() . '/file.zip';
// Or:
$file = 'C:\\path\\to\\file.zip';
?>
This worked for me on Windows at least. I'm not sure about other platforms.


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