From de84cc4d60bc1e152b97a0603603e516da5c8e88 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 19 Nov 2019 17:07:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- .../admin/controller/agent/AgentManage.php | 4 +- .../app/admin/controller/article/Article.php | 2 +- .../controller/article/ArticleCategory.php | 2 +- .../admin/controller/article/WechatNews.php | 2 +- .../admin/controller/setting/SystemConfig.php | 2 +- .../controller/setting/SystemGroupData.php | 2 +- .../app/admin/controller/store/CopyTaobao.php | 2 +- .../admin/controller/store/StoreCategory.php | 2 +- .../admin/controller/store/StoreInfoMana.php | 2 +- .../admin/controller/store/StoreProduct.php | 2 +- .../controller/system/SystemAttachment.php | 2 +- .../app/admin/controller/ump/StoreSeckill.php | 2 +- crmeb/app/admin/controller/wechat/Reply.php | 4 +- .../admin/controller/wechat/StoreService.php | 2 +- crmeb/app/admin/controller/widget/Images.php | 2 +- crmeb/app/api/controller/PublicController.php | 2 +- .../activity/StoreBargainController.php | 2 +- .../activity/StoreCombinationController.php | 2 +- .../store/StoreProductController.php | 2 +- .../controller/user/UserBillController.php | 2 +- crmeb/crmeb/services/UploadService.php | 93 ++++--------------- crmeb/crmeb/services/UtilService.php | 2 +- 23 files changed, 46 insertions(+), 97 deletions(-) diff --git a/.gitignore b/.gitignore index aa45a3c6..a8d882d3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ runtime/ install.lock public/uploads -remarks.txt \ No newline at end of file +remarks.txt +*.jpg +*.png diff --git a/crmeb/app/admin/controller/agent/AgentManage.php b/crmeb/app/admin/controller/agent/AgentManage.php index 13b575d7..2f31a1db 100644 --- a/crmeb/app/admin/controller/agent/AgentManage.php +++ b/crmeb/app/admin/controller/agent/AgentManage.php @@ -211,7 +211,7 @@ class AgentManage extends AuthController if(!$imageInfo){ $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); if(!$res) throw new \think\Exception('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); + $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); if(!is_array($imageInfo)) return $imageInfo; SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']); RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); @@ -246,7 +246,7 @@ class AgentManage extends AuthController if(!$imageInfo){ $res = \app\models\routine\RoutineCode::getShareCode($uid, 'spread', '', ''); if(!$res) return JsonService::fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); + $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); if(!is_array($imageInfo)) return JsonService::fail($imageInfo); SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time']); RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); diff --git a/crmeb/app/admin/controller/article/Article.php b/crmeb/app/admin/controller/article/Article.php index 0625152d..155f0faf 100644 --- a/crmeb/app/admin/controller/article/Article.php +++ b/crmeb/app/admin/controller/article/Article.php @@ -99,7 +99,7 @@ class Article extends AuthController * @return \think\response\Json */ public function upload_image(){ - $res = Upload::getInstance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); + $res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); if(!is_array($res)) return Json::fail($res); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); return Json::successful('上传成功!',['url'=>$res['dir']]); diff --git a/crmeb/app/admin/controller/article/ArticleCategory.php b/crmeb/app/admin/controller/article/ArticleCategory.php index d1203c52..78abcc07 100644 --- a/crmeb/app/admin/controller/article/ArticleCategory.php +++ b/crmeb/app/admin/controller/article/ArticleCategory.php @@ -72,7 +72,7 @@ class ArticleCategory extends AuthController * s上传图片 * */ public function upload(){ - $res = Upload::getInstance()->setUploadPath('article')->image('file'); + $res = Upload::instance()->setUploadPath('article')->image('file'); if(!is_array($res)) return Json::fail($res); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/article/WechatNews.php b/crmeb/app/admin/controller/article/WechatNews.php index 16466d92..2339a525 100644 --- a/crmeb/app/admin/controller/article/WechatNews.php +++ b/crmeb/app/admin/controller/article/WechatNews.php @@ -89,7 +89,7 @@ class WechatNews extends AuthController * @return \think\response\Json */ public function upload_image(){ - $res = Upload::getInstance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); + $res = Upload::instance()->setUploadPath('wechat/image/'.date('Ymd'))->image($_POST['file']); if(!is_array($res)) return Json::fail($res); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],5,$res['image_type'],$res['time']); return Json::successful('上传成功!',['url'=>$res['thumb_path']]); diff --git a/crmeb/app/admin/controller/setting/SystemConfig.php b/crmeb/app/admin/controller/setting/SystemConfig.php index d8aa5444..75b4ed02 100644 --- a/crmeb/app/admin/controller/setting/SystemConfig.php +++ b/crmeb/app/admin/controller/setting/SystemConfig.php @@ -400,7 +400,7 @@ class SystemConfig extends AuthController * 文件上传 * */ public function file_upload(){ - $res = Upload::getInstance()->setUploadPath('config/file')->file($this->request->param('file','file')); + $res = Upload::instance()->setUploadPath('config/file')->file($this->request->param('file','file')); if(!$res->status) return Json::fail($res->error); return Json::successful('上传成功!',['filePath'=>$res->filePath]); } diff --git a/crmeb/app/admin/controller/setting/SystemGroupData.php b/crmeb/app/admin/controller/setting/SystemGroupData.php index 413168fe..768b9f98 100644 --- a/crmeb/app/admin/controller/setting/SystemGroupData.php +++ b/crmeb/app/admin/controller/setting/SystemGroupData.php @@ -255,7 +255,7 @@ class SystemGroupData extends AuthController public function upload() { - $res = Upload::getInstance()->setUploadPath('common')->image('file'); + $res = Upload::instance()->setUploadPath('common')->image('file'); if(!is_array($res)) return Json::fail($res); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],6,$res['image_type'],$res['time']); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/store/CopyTaobao.php b/crmeb/app/admin/controller/store/CopyTaobao.php index 996dbbae..3ed38bcf 100644 --- a/crmeb/app/admin/controller/store/CopyTaobao.php +++ b/crmeb/app/admin/controller/store/CopyTaobao.php @@ -770,7 +770,7 @@ class CopyTaobao extends AuthController $size = strlen(trim($content)); if (!$content || $size <= 2) return '图片流获取失败'; $date_dir = date('Y') . DS . date('m') . DS . date('d'); - $imageInfo = UploadService::getInstance()->setUploadPath('attach/' . $date_dir)->imageStream($name, $content); + $imageInfo = UploadService::instance()->setUploadPath('attach/' . $date_dir)->imageStream($name, $content); if (!is_array($imageInfo)) return $imageInfo; $date['path'] = $imageInfo['dir']; $date['name'] = $imageInfo['name']; diff --git a/crmeb/app/admin/controller/store/StoreCategory.php b/crmeb/app/admin/controller/store/StoreCategory.php index 449f5cc0..754142d4 100644 --- a/crmeb/app/admin/controller/store/StoreCategory.php +++ b/crmeb/app/admin/controller/store/StoreCategory.php @@ -107,7 +107,7 @@ class StoreCategory extends AuthController */ public function upload() { - $res = Upload::getInstance()->setUploadPath('store/category'.date('Ymd'))->image('file'); + $res = Upload::instance()->setUploadPath('store/category'.date('Ymd'))->image('file'); if(is_array($res)){ SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/store/StoreInfoMana.php b/crmeb/app/admin/controller/store/StoreInfoMana.php index 8c28c30c..98ad977c 100644 --- a/crmeb/app/admin/controller/store/StoreInfoMana.php +++ b/crmeb/app/admin/controller/store/StoreInfoMana.php @@ -68,7 +68,7 @@ class StoreInfoMana extends AuthController * */ public function upload() { - $res = Upload::getInstance()->setUploadPath('article/'.date('Ymd'))->image('file'); + $res = Upload::instance()->setUploadPath('article/'.date('Ymd'))->image('file'); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']); if(is_array($res)) return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/store/StoreProduct.php b/crmeb/app/admin/controller/store/StoreProduct.php index bc4ba4fc..4b6a8fbc 100644 --- a/crmeb/app/admin/controller/store/StoreProduct.php +++ b/crmeb/app/admin/controller/store/StoreProduct.php @@ -176,7 +176,7 @@ class StoreProduct extends AuthController */ public function upload() { - $res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); + $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],1,$res['image_type'],$res['time']); if(is_array($res)) return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/system/SystemAttachment.php b/crmeb/app/admin/controller/system/SystemAttachment.php index 1f3d0df3..5e65268e 100644 --- a/crmeb/app/admin/controller/system/SystemAttachment.php +++ b/crmeb/app/admin/controller/system/SystemAttachment.php @@ -21,7 +21,7 @@ class SystemAttachment extends AuthController */ public function upload() { - $res = Upload::getInstance()->setUploadPath('editor/'.date('Ymd'))->image('upfile'); + $res = Upload::instance()->setUploadPath('editor/'.date('Ymd'))->image('upfile'); if(is_array($res)){ SystemAttachmentModel::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']); $info["originalName"] = $res['name']; diff --git a/crmeb/app/admin/controller/ump/StoreSeckill.php b/crmeb/app/admin/controller/ump/StoreSeckill.php index 25ea8d17..825c0f0c 100644 --- a/crmeb/app/admin/controller/ump/StoreSeckill.php +++ b/crmeb/app/admin/controller/ump/StoreSeckill.php @@ -191,7 +191,7 @@ class StoreSeckill extends AuthController */ public function upload() { - $res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); + $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); if(is_array($res)){ SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],4,$res['image_type'],$res['time']); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/wechat/Reply.php b/crmeb/app/admin/controller/wechat/Reply.php index 5853d4cf..a347ef70 100644 --- a/crmeb/app/admin/controller/wechat/Reply.php +++ b/crmeb/app/admin/controller/wechat/Reply.php @@ -82,7 +82,7 @@ class Reply extends AuthController { $name = $this->request->post('file'); if(!$name) return Json::fail('请上传图片'); - $res = Upload::getInstance()->setUploadType(1)->setUploadPath('wechat/image') + $res = Upload::instance()->setUploadType(1)->setUploadPath('wechat/image') ->setAutoValidate(true)->image($name); if(!is_array($res)) return Json::fail($res); SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],0,$res['image_type'],$res['time']); @@ -93,7 +93,7 @@ class Reply extends AuthController { $name = $this->request->post('file'); if(!$name) return Json::fail('请上传声音'); - $res = Upload::getInstance()->setUploadPath('wechat/voice')->setAutoValidate(true)->file($name); + $res = Upload::instance()->setUploadPath('wechat/voice')->setAutoValidate(true)->file($name); return $res->status === true ? Json::successful('上传成功',$res->filePath) : Json::fail($res->error); } diff --git a/crmeb/app/admin/controller/wechat/StoreService.php b/crmeb/app/admin/controller/wechat/StoreService.php index dc244c1f..38ca2c53 100644 --- a/crmeb/app/admin/controller/wechat/StoreService.php +++ b/crmeb/app/admin/controller/wechat/StoreService.php @@ -136,7 +136,7 @@ class StoreService extends AuthController */ public function upload() { - $res = Upload::getInstance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); + $res = Upload::instance()->setUploadPath('store/product/'.date('Ymd'))->image('file'); if(is_array($res)){ SystemAttachment::attachmentAdd($res['name'],$res['size'],$res['type'],$res['dir'],$res['thumb_path'],2,$res['image_type'],$res['time']); return Json::successful('图片上传成功!',['name'=>$res['name'],'url'=>Upload::pathToUrl($res['thumb_path'])]); diff --git a/crmeb/app/admin/controller/widget/Images.php b/crmeb/app/admin/controller/widget/Images.php index 645951f6..8c7ae19a 100644 --- a/crmeb/app/admin/controller/widget/Images.php +++ b/crmeb/app/admin/controller/widget/Images.php @@ -71,7 +71,7 @@ class Images extends AuthController $upload_type = $this->request->get('upload_type',0); try{ $path = make_path('attach',2,true); - $res = Upload::getInstance()->setUploadPath($path)->setAutoValidate(true) + $res = Upload::instance()->setUploadPath($path)->setAutoValidate(true) ->setUploadType($upload_type)->image('file'); if(is_object($res) && $res->status === false){ $info = array( diff --git a/crmeb/app/api/controller/PublicController.php b/crmeb/app/api/controller/PublicController.php index bed15fbb..cd1c11c8 100644 --- a/crmeb/app/api/controller/PublicController.php +++ b/crmeb/app/api/controller/PublicController.php @@ -137,7 +137,7 @@ class PublicController ],$request); if(!$data['filename']) return app('json')->fail('参数有误'); if(Cache::has('start_uploads_'.$request->uid()) && Cache::get('start_uploads_'.$request->uid()) >= 100) return app('json')->fail('非法操作'); - $res = UploadService::getInstance()->setUploadPath('store/comment')->image($data['filename']); + $res = UploadService::instance()->setUploadPath('store/comment')->image($data['filename']); if(!is_array($res)) return app('json')->fail($res); SystemAttachment::attachmentAdd($res['name'], $res['size'], $res['type'], $res['dir'], $res['thumb_path'],1, $res['image_type'], $res['time'], 2); if(Cache::has('start_uploads_'.$request->uid())) diff --git a/crmeb/app/api/controller/activity/StoreBargainController.php b/crmeb/app/api/controller/activity/StoreBargainController.php index da7f8fb3..c9ab274b 100644 --- a/crmeb/app/api/controller/activity/StoreBargainController.php +++ b/crmeb/app/api/controller/activity/StoreBargainController.php @@ -314,7 +314,7 @@ class StoreBargainController if($user['is_promoter'] || sysConfig('store_brokerage_statu') == 2) $valueData.='&pid='.$user['uid']; $res = RoutineCode::getPageCode('pages/activity/goods_bargain_details/index',$valueData,280); if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/activity/bargain/code')->imageStream($name,$res); + $imageInfo = UploadService::instance()->setUploadPath('routine/activity/bargain/code')->imageStream($name,$res); if(!is_array($imageInfo)) return app('json')->fail($imageInfo); if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); diff --git a/crmeb/app/api/controller/activity/StoreCombinationController.php b/crmeb/app/api/controller/activity/StoreCombinationController.php index c56256b6..82ee6bbe 100644 --- a/crmeb/app/api/controller/activity/StoreCombinationController.php +++ b/crmeb/app/api/controller/activity/StoreCombinationController.php @@ -204,7 +204,7 @@ class StoreCombinationController if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $valueData.='&pid='.$user['uid']; $res = RoutineCode::getPageCode('pages/activity/goods_combination_status/index',$valueData,280); if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/activity/pink/code')->imageStream($name,$res); + $imageInfo = UploadService::instance()->setUploadPath('routine/activity/pink/code')->imageStream($name,$res); if(!is_array($imageInfo)) return app('json')->fail($imageInfo); if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); diff --git a/crmeb/app/api/controller/store/StoreProductController.php b/crmeb/app/api/controller/store/StoreProductController.php index 8c6ebd5c..6093175b 100644 --- a/crmeb/app/api/controller/store/StoreProductController.php +++ b/crmeb/app/api/controller/store/StoreProductController.php @@ -79,7 +79,7 @@ class StoreProductController if($user['is_promoter'] || sysConfig('store_brokerage_statu')==2) $data.='&pid='.$user['uid']; $res = \app\models\routine\RoutineCode::getPageCode('pages/goods_details/index',$data,280); if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = \crmeb\services\UploadService::getInstance()->setUploadPath('routine/product')->imageStream($name,$res); + $imageInfo = \crmeb\services\UploadService::instance()->setUploadPath('routine/product')->imageStream($name,$res); if(is_string($imageInfo)) return app('json')->fail($imageInfo); if($imageInfo['image_type'] == 1) $remoteImage = UtilService::remoteImage($siteUrl.$imageInfo['dir']); else $remoteImage = UtilService::remoteImage($imageInfo['dir']); diff --git a/crmeb/app/api/controller/user/UserBillController.php b/crmeb/app/api/controller/user/UserBillController.php index 245602b7..94015c20 100644 --- a/crmeb/app/api/controller/user/UserBillController.php +++ b/crmeb/app/api/controller/user/UserBillController.php @@ -166,7 +166,7 @@ class UserBillController if(!$imageInfo){ $res = RoutineCode::getShareCode($user['uid'], 'spread', '', ''); if(!$res) return app('json')->fail('二维码生成失败'); - $imageInfo = UploadService::getInstance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); + $imageInfo = UploadService::instance()->setUploadPath('routine/spread/code')->imageStream($name,$res['res']); if(!is_array($imageInfo)) return app('json')->fail($imageInfo); SystemAttachment::attachmentAdd($imageInfo['name'],$imageInfo['size'],$imageInfo['type'],$imageInfo['dir'],$imageInfo['thumb_path'],1,$imageInfo['image_type'],$imageInfo['time'],2); RoutineQrcode::setRoutineQrcodeFind($res['id'],['status'=>1,'time'=>time(),'qrcode_url'=>$imageInfo['dir']]); diff --git a/crmeb/crmeb/services/UploadService.php b/crmeb/crmeb/services/UploadService.php index 5e05e0b6..af6cb70d 100644 --- a/crmeb/crmeb/services/UploadService.php +++ b/crmeb/crmeb/services/UploadService.php @@ -10,13 +10,23 @@ namespace crmeb\services; use crmeb\services\storage\COS; use crmeb\services\storage\OSS; use crmeb\services\storage\Qiniu; -use crmeb\services\SystemConfigService; +use crmeb\traits\LogicTrait; use think\exception\ValidateException; use think\facade\Filesystem; use think\File; +/** + * Class UploadService + * @package crmeb\services + * @method $this setReturnErr(bool $returnErr) 设置发生错误时是否返回错误信息 + * @method $this setAutoValidate(bool $autoValidate) 设置是否校验上传文件 + * @method $this setUploadType(int $uploadType) 设置上传类型 + * @method $this setImageValidate(string $imageValidate) 设置上传图片大小等验证信息 + * @method $this setUploadPath(string $uploadPath) 设置文件上传路径 + */ class UploadService { + use LogicTrait; /** * 文件校验 * @var bool @@ -61,87 +71,24 @@ class UploadService */ private static $uploadStatus; - /** - * 本类实例化 - * @var - */ - protected static $instance; - /** * 上传图片的大小 2MB 单位字节 * @var string */ protected $imageValidate = 'filesize:2097152|fileExt:jpg,jpeg,png,gif,pem|fileMime:image/jpeg,image/gif,image/png,text/plain'; + protected $propsRule = [ + 'returnErr' => false, + 'autoValidate' => false, + 'uploadPath' => null, + 'uploadType' => null, + ]; + protected function __construct() { self::init(); } - /** - * @return UploadService - */ - public static function getInstance() - { - if (is_null(self::$instance)) self::$instance = new self(); - return self::$instance; - } - - /** - * 设置上传图片大小等验证信息 - * @param string $imageValidate - * @return $this - */ - public function setImageValidate(string $imageValidate) - { - $this->imageValidate = $imageValidate; - return $this; - } - - /** - * 设置是否校验上传文件 - * @param bool $autoValidate - * @return $this - */ - public function setAutoValidate(bool $autoValidate) - { - $this->autoValidate = $autoValidate; - return $this; - } - - /** - * 设置上传路径 - * @param string $uploadPath - * @return $this - */ - public function setUploadPath(string $uploadPath) - { - $this->uploadPath = $uploadPath; - return $this; - } - - /** - * 设置上传类型 - * @param int $uploadType - * @return $this - */ - public function setUploadType(int $uploadType) - { - $this->uploadType = $uploadType; - return $this; - } - - /** - * 设置发生错误时是否返回错误信息 - * @param bool $returnErr - * @return $this - */ - public function serReturnErr(bool $returnErr) - { - $this->returnErr = $returnErr; - return $this; - } - /** * 初始化 */ @@ -465,8 +412,8 @@ class UploadService return DS . $savePath; } - protected function __clone() + protected function __destruct() { - // TODO: Implement __clone() method. + // TODO: Implement __destruct() method. } } \ No newline at end of file diff --git a/crmeb/crmeb/services/UtilService.php b/crmeb/crmeb/services/UtilService.php index 4a7af013..cf617782 100644 --- a/crmeb/crmeb/services/UtilService.php +++ b/crmeb/crmeb/services/UtilService.php @@ -511,7 +511,7 @@ class UtilService $res = ob_get_contents(); ob_end_clean(); $key = substr(md5(rand(0, 9999)), 0, 5) . date('YmdHis') . rand(0, 999999) . '.jpg'; - return UploadService::getInstance()->setUploadPath($path)->imageStream($key, $res); + return UploadService::instance()->setUploadPath($path)->imageStream($key, $res); } /*