// 处理照片压缩包 $zip = new \ZipArchive(); // 获取压缩包内容照片数量 $path = 'static/oa/img/staImport/' . date('Ymd') . '/' . date('His'); if ($zip->open($param['fileUrl']) === TRUE) { for ($i = 0; $i < $zip->numFiles; $i++) { $statInfo = $zip->statIndex($i, \ZipArchive::FL_ENC_RAW); if (mb_detect_encoding($statInfo['name']) != 'UTF-8') { $zip->renameIndex($i, iconv('GBK', 'UTF-8//IGNORE', $statInfo['name'])); } } $zip->close(); $zip->open($param['fileUrl']); // 解压文件到 指定目录 $zip->extractTo($path); $zip->close(); } else { return '打开zip文件失败,请重新上传zip文件'; }
标签:解压,zip,ZipArchive,statInfo,close,php,压缩包 From: https://www.cnblogs.com/mldyfre/p/18321308