打开php.ini.
加一行
extension=php_rar.dll
重启web服务器 和php
复制代码 代码如下:
public function _unzip($filename,$extractto){
$filename = iconv('utf-8','gb2312',"upload/zip/8月.rar");
// echo $filename . '</br>';
$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('</br>entry not found');
$entry->extract($extractto); // extract to the current dir
}
rar_close($rar_file);
}
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!