|
ZipArchive::addFile
Adds a file to a ZIP archive from the given path
()
Example 2693. Open and extract<?php Code Examples / Notes » ziparchive_addfileandreas r. newsgroups2005
Currently the number of files that can be added using addFile to the ZIP archive (until it is closed) is limited by file descriptors limit. This is an easy workaround (on the bug links below you can find another workarounds): <?php /** work around file descriptor number limitation (to avoid failure * upon adding more than typically 253 or 1024 files to ZIP) */ function addFileToZip( $zip, $path, $zipEntryName ) { // this would fail with status ZIPARCHIVE::ER_OPEN // after certain number of files is added since // ZipArchive internally stores the file descriptors of all the // added files and only on close writes the contents to the ZIP file // see: http://bugs.php.net/bug.php?id=40494 // and: http://pecl.php.net/bugs/bug.php?id=9443 // return $zip->addFile( $path, $zipEntryName ); $contents = file_get_contents( $path ); if ( $contents === false ) { return false; } return $zip->addFromString( $zipEntryName, $contents ); } ?> |
Change Languagezip_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 |