note 74297 added to function.ziparchive-addfile
| From: | AndreasR dot newsgroups2005atgeekmailde at osu1 dot php dot net | Date: | Wed, 04 Apr 2007 01:29:23 +0000 |
| Subject: | note 74297 added to function.ziparchive-addfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125073@lists.php.net to get a copy of this message | ||
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 );
}
?>
----
Server IP: 217.13.201.10
Probable Submitter: 89.55.76.72
----
Manual Page -- http://www.php.net/manual/en/function.ziparchive-addfile.php
Edit -- https://master.php.net/note/edit/74297
Del: integrated -- https://master.php.net/note/delete/74297/integrated
Del: useless -- https://master.php.net/note/delete/74297/useless
Del: bad code -- https://master.php.net/note/delete/74297/bad+code
Del: spam -- https://master.php.net/note/delete/74297/spam
Del: non-english -- https://master.php.net/note/delete/74297/non-english
Del: in docs -- https://master.php.net/note/delete/74297/in+docs
Del: other reasons-- https://master.php.net/note/delete/74297
Reject -- https://master.php.net/note/reject/74297
Search -- https://master.php.net/manage/user-notes.php