suche nach in der

ZipArchive::renameIndex> <ZipArchive::locateName
Last updated: Fri, 25 May 2012

view this page in

ZipArchive::open

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

ZipArchive::openÖffnet ein ZIP-Dateiarchiv

Beschreibung

mixed ZipArchive::open ( string $filename [, int $flags ] )

Öffnet ein neues ZIP-Archiv für Lese-, Schreib- und Veränderungszugriffe.

Parameter-Liste

filename

Der Name des zu öffnenden ZIP-Archivs.

flags

Der Modus, in dem das zu öffnende Archiv verwendet werden soll.

  • ZIPARCHIVE::OVERWRITE

  • ZIPARCHIVE::CREATE

  • ZIPARCHIVE::EXCL

  • ZIPARCHIVE::CHECKCONS

Rückgabewerte

Fehlercodes

Gibt TRUE oder den Fehlercode zurück.

  • ZIPARCHIVE::ER_EXISTS

  • ZIPARCHIVE::ER_INCONS

  • ZIPARCHIVE::ER_INVAL

  • ZIPARCHIVE::ER_MEMORY

  • ZIPARCHIVE::ER_NOENT

  • ZIPARCHIVE::ER_NOZIP

  • ZIPARCHIVE::ER_OPEN

  • ZIPARCHIVE::ER_READ

  • ZIPARCHIVE::ER_SEEK

Beispiele

Beispiel #1 Öffnen und extrahieren

<?php
$zip 
= new ZipArchive;
$res $zip->open('test.zip');
if (
$res === TRUE) {
    echo 
'ok';
    
$zip->extractTo('test');
    
$zip->close();
} else {
    echo 
'Fehler, Code:' $res;
}
?>

Beispiel #2 Ein Archiv erstellen

<?php
$zip 
= new ZipArchive;
$res $zip->open('test.zip'ZipArchive::CREATE);
if (
$res === TRUE) {
    
$zip->addFromString('test.txt''Der Dateiinhalt kommt hier');
    
$zip->addFile('data.txt''eintragsname.txt');
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'Fehler';
}
?>


add a note add a note User Contributed Notes
ZipArchive::open
rickky at gmail dot com
02-Jul-2007 02:07
If the directory you are writing or saving into does not have the correct permissions set, you won't get any error messages and it will look like everything worked fine... except it won't have changed!

Instead make sure you collect the return value of ZipArchive::close(). If it is false... it didn't work.

ZipArchive::renameIndex> <ZipArchive::locateName
Last updated: Fri, 25 May 2012