function unzipNew($filePath, $topath)
{
if (empty($topath) || empty($filePath)) {
return false;
}
$zip = new \ZipArchive();
if ($zip->open($filePath) === true) {
if(true){
for($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
$t = explode('.',$filename);
if(count($t) == 2){
$s = $zip->getStream($filename);
$data = stream_get_contents($s);
file_put_contents($topath.'/'.$filename, $data);
}else{
@mkdir($topath.'/'.$filename, 0777);
}
}
}
$zip->close();
return true;
} else {
return false;
}
}
03-12
272
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-11
171
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-24
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-23