2016-04-28 41 views
0

我想提取.rar文件沒有.zip文件使用PHP 我跟PHP手冊文件解壓.rar程序到指定目錄中的PHP

php manual

的問題,在這個例子中本教程不提取文件到目錄, 它將文件的內容打印到瀏覽器。

+0

確保您有[安裝](http://php.net/manual/en/rar.installation.php)插件。然後查找[在這篇文章](http://stackoverflow.com/questions/14555730/how-to-extract-rar-archive-files-and-folders-using-php-in-windows):) – Jer

+0

是的我沒有,php_rar.dll –

回答

1

您應該能夠使用RarEntry::extract方法從存檔中提取文件。

因此,像:

$archive = RarArchive::open('archive.rar'); 
$entries = $archive->getEntries(); 
foreach ($entries as $entry) { 
    $entry->extract('/extract/to/this/path'); 
} 
$archive->close(); 
+0

非常感謝你:) :) –