2010-04-25 38 views
0

如果我有,其結構是一個ZIP文件:提取從ZIP中特定文件的PHP

-directory1 DIR 
     -files in here 
    -directory2 DIR 
     -more files in here 

使用pclzip.lib.php我怎麼能打開這個ZIP文件並解壓directory1目錄(遞歸)到一個目錄然後將directory2(遞歸)提取到另一個目錄中。

回答

0

您應該可以使用PCLZIP_OPT_BY_NAME選項來選擇要提取的檔案內的哪個路徑。 PCLZIP_OPT_PATH應該確定分支將被寫入的位置。

但這只是瀏覽後的猜測the manual - 我從來沒有使用過這個特定的庫。

0
<?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'; 
} 
?> 
+0

這是一個zip擴展的例子,它不是pclzip。 – 2013-02-22 12:05:43