mmykdbc
 /**
     * 读取压缩包目录
     */
    public function getDecompression()
    {
        $url = public_path(\'uxradar.zip\');
        $zipper = new \ZipArchive();
        $zipStatus = $zipper->open($url);
        if ($zipStatus !== true) {
            throw new \Exception(\'Could not open ZIP file. Error code: \' . $zipStatus);
        }
        $filesInside = [];
        for ($i = 0; $i < $zipper->count(); $i++) {
            array_push($filesInside, $zipper->getNameIndex($i));
        }
        $zipper->close();
        return $filesInside;
    }

    /**
     * 代码压缩包详细文件信息
     * @param int $id
     * @return array
     */
    public function getDecompressionDetail()
    {
        $zipPath = public_path(\'uxradar.zip\');
        $content = false;
        $zip = new \ZipArchive();
        if ($zip->open($zipPath) === true) {
            $content = $zip->getFromName(\'uxradar/1.txt\');
            $content = $content && iconv(\'GBK\', \'UTF-8\', $content);
            $zip->close();
        }
        return $this->success($content);
    }

  一定要确定自己的php环境安装了zip扩展,文件目录:

 

分类:

技术点:

相关文章:

  • 2021-10-07
  • 2021-12-16
  • 2021-09-22
  • 2021-11-07
  • 2018-02-07
  • 2021-10-06
猜你喜欢
  • 2021-09-17
  • 2021-11-18
  • 2021-10-20
  • 2021-11-07
  • 2021-09-20
  • 2021-11-21
  • 2021-11-07
相关资源
相似解决方案