downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

ZipArchive::addFromString> <ZipArchive::addEmptyDir
[edit] Last updated: Fri, 24 Jun 2011

view this page in

ZipArchive::addFile

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

ZipArchive::addFileاضافه کردن فایل به آرشیو ZIP در مسیر داده شده

Description

bool ZipArchive::addFile ( string $filename [, string $localname ] )

اضافه کردن فایل به آرشیو ZIP در مسیر داده شده.

Parameters

filename

مسیر فایل برای اضافه کردن.

localname

نام محلی در آرشیو ZIP.

Return Values

Returns TRUE on success or FALSE on failure.

Examples

این مثال فایل آرشیو ZIP test.zip را باز کرده و فایل /path/to/index.txt را به آن اضافه می‌کند. as newname.txt.

Example #1 باز کردن و استخراج

<?php
$zip 
= new ZipArchive;
if (
$zip->open('test.zip') === TRUE) {
    
$zip->addFile('/path/to/index.txt''newname.txt');
    
$zip->close();
    echo 
'ok';
} else {
    echo 
'failed';
}
?>


add a note add a note User Contributed Notes ZipArchive::addFile - [1 notes]
up
0
bretscher at 5sl dot org
9 months ago
Always check if the file $filename exists. Zip file generation will fail without any warning if it does not.

 
show source | credits | sitemap | contact | advertising | mirror sites