时间:2021-07-01 10:21:17 帮助过:4人阅读
public function _unzip($fileName,$extractTO){
$fileName = iconv('utf-8','gb2312',"upload/zip/8月.rar");
// echo $fileName . '';
$extractTo = "upload/zip/TEST/";
$rar_file = rar_open($fileName) or die('could not open rar');
$list = rar_list($rar_file) or die('could not get list');
// print_r($list);
foreach($list as $file) {
$pattern = '/\".*\"/';
preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE);
$pathStr=$matches[0][0];
$pathStr=str_replace("\"",'',$pathStr);
// print_r($pathStr);
$entry = rar_entry_get($rar_file, $pathStr) or die('entry not found');
$entry->extract($extractTo); // extract to the current dir
}
rar_close($rar_file);
}