extract .rar files to a specific directory in php

不问归期 提交于 2019-12-10 12:04:10

问题


I want to extract .rar file not .zip file using php I followed this example in php manual

php manual

the problem in this tutorial is not extract the files to directory, it prints the content of the file to browser.


回答1:


You should be able to extract the files from the archive with the RarEntry::extract method.

So something like:

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



回答2:


btw: extract offers overwrite as third parameter (second being an array of paths to extract)



来源:https://stackoverflow.com/questions/36914245/extract-rar-files-to-a-specific-directory-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!