|
打開php.ini.
加一行
extension=php_rar.dll
重啟web服務(wù)器 和php
復(fù)制代碼 代碼如下:
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);
}
php技術(shù):php 解壓rar文件及zip文件的方法,轉(zhuǎn)載需保留來(lái)源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。