array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'ziparchive.extractto.php', 1 => 'ZipArchive::extractTo', 2 => 'Extract the archive contents', ), 'up' => array ( 0 => 'class.ziparchive.php', 1 => 'ZipArchive', ), 'prev' => array ( 0 => 'ziparchive.deletename.php', 1 => 'ZipArchive::deleteName', ), 'next' => array ( 0 => 'ziparchive.getarchivecomment.php', 1 => 'ZipArchive::getArchiveComment', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/zip/ziparchive/extractto.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

ZipArchive::extractTo

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

ZipArchive::extractToExtract the archive contents

Опис

public ZipArchive::extractTo(string $pathto, array|string|null $files = null): bool

Extract the complete archive or the given files to the specified destination.

Увага

The default permissions for extracted files and directories give the widest possible access. This can be restricted by setting the current umask, which can be changed using umask().

For security reasons, the original permissions are not restored. For an example of how to restore them, see the code sample on the ZipArchive::getExternalAttributesIndex() page.

Параметри

pathto

Location where to extract the files.

files

The entries to extract. It accepts either a single entry name or an array of names.

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Приклади

Приклад #1 Extract all entries

<?php
$zip
= new ZipArchive;
if (
$zip->open('test.zip') === TRUE) {
$zip->extractTo('/my/destination/dir/');
$zip->close();
echo
'ok';
} else {
echo
'failed';
}
?>

Приклад #2 Extract two entries

<?php
$zip
= new ZipArchive;
$res = $zip->open('test_im.zip');
if (
$res === TRUE) {
$zip->extractTo('/my/destination/dir/', array('pear_item.gif', 'testfromfile.php'));
$zip->close();
echo
'ok';
} else {
echo
'failed';
}
?>

Примітки

Зауваження:

Файлові системи Windows NTFS не підтримують використання деяких символів у назвах файлів, а саме <|>*?":. Не підтримуються також назви файлів з крапкою в кінці. На відміну від деяких інструментів розпакування, цей метод не замінює ці символи на підкреслення, а натомість не витягує такі файли.