From 43a150f2d3dd2fb1c72382e298b07e43b2722ac1 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Tue, 19 Oct 2021 17:12:44 +0800 Subject: [PATCH] =?UTF-8?q?zip=E7=B1=BB=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/base/ZipFolder.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/extend/base/ZipFolder.php b/extend/base/ZipFolder.php index e9ce15477..1e4364d3b 100755 --- a/extend/base/ZipFolder.php +++ b/extend/base/ZipFolder.php @@ -32,7 +32,12 @@ class ZipFolder */ public function __construct() { - $this->zip = new \ZipArchive(); + if(class_exists('ZipArchive')) + { + $this->zip = new \ZipArchive(); + } else { + throw new \Exception("当前PHP环境无Zip扩展"); + } } /** @@ -81,7 +86,7 @@ class ZipFolder $this->ignored_names = is_array($ignored) ? $ignored : ($ignored ? array($ignored) : array()); if($this->zip->open($zipfile, \ZipArchive::CREATE) !== true) { - throw new Exception("cannot open <$zipfile>\n"); + throw new \Exception("cannot open <$zipfile>\n"); } $folder = substr($folder, -1) == '/' ? substr($folder, 0, strlen($folder)-1) : $folder; if(strstr($folder, '/'))