Extracting specific files from ZIP in PHP

≡放荡痞女 提交于 2019-12-01 13:44:01

You should be able to use the PCLZIP_OPT_BY_NAME option to select which path inside the archive you want to extract. PCLZIP_OPT_PATH ought to determine where that branch will be written.

But that's just a guess after browsing the manual -- I've never used this particular library.

<?php
$zip = new ZipArchive;
$res = $zip->open('test_im.zip');
if ($res === TRUE) {
    $zip->extractTo('directory1', array('item.gif', 'file1.php'));
    $zip->extractTo('directory2', array('item1.gif', 'file2.php'));
    $zip->close();
    echo 'ok';
} else {
    echo 'failed';
}
?>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!