IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
96 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual


(PHP 5 >= 5.2.0, PECL zip >= 1.1.0)

ZipArchive::addFileAdds a file to a ZIP archive from the given path


bool ZipArchive::addFile ( string $filename [, string $localname = NULL [, int $start = 0 [, int $length = 0 ]]] )

Adds a file to a ZIP archive from a given path.



The path to the file to add.


If supplied, this is the local name inside the ZIP archive that will override the filename.


This parameter is not used but is required to extend ZipArchive.


This parameter is not used but is required to extend ZipArchive.

Return Values

Returns TRUE on success or FALSE on failure.


This example opens a ZIP file archive and add the file /path/to/index.txt. as newname.txt.

Example #1 Open and extract

= new ZipArchive;
if (
$zip->open('') === TRUE) {
} else {



When a file is set to be added to the archive, PHP will attempt to lock the file and it is only released once the ZIP operation is done. In short, it means you can first delete an added file after the archive is closed.

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP