| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 | 
							- <?php
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Created by Yunbao
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Author: https://gitee.com/yunbaokeji
 
- // +—————————————————————————————————————————————————————————————————————
 
- // | Date: 2022-02-17
 
- // +—————————————————————————————————————————————————————————————————————
 
- namespace app\user\controller;
 
- use cmf\controller\AdminBaseController;
 
- use cmf\lib\Upload;
 
- use think\facade\View;
 
- if (!function_exists('Aws\constantly')) {
 
-     require CMF_ROOT . 'sdk/aws/aws-autoloader.php';
 
- }
 
- use Aws\S3\S3Client;
 
- /**
 
-  * 附件上传控制器
 
-  * Class Asset
 
-  * @package app\asset\controller
 
-  */
 
- class AssetController extends AdminBaseController
 
- {
 
-     public function initialize()
 
-     {
 
-         $adminId = cmf_get_current_admin_id();
 
-         $userId  = cmf_get_current_user_id();
 
-         if (empty($adminId) && empty($userId)) {
 
-             $this->error("非法上传!");
 
-         }
 
-         connectionRedis();
 
-     }
 
-     /**
 
-      * webuploader 上传
 
-      */
 
-     public function webuploaderBF(){
 
-         if ($this->request->isPost()) {
 
-             $uploader = new Upload();
 
-             $result = $uploader->upload();
 
-             if ($result === false) {
 
-                 $this->error($uploader->getError());
 
-             } else {
 
-                 $this->success("上传成功!", '', $result);
 
-             }
 
-         } else {
 
-             $uploadSetting = cmf_get_upload_setting();
 
-             $arrFileTypes = [
 
-                 'image' => ['title' => 'Image files', 'extensions' => $uploadSetting['file_types']['image']['extensions']],
 
-                 'video' => ['title' => 'Video files', 'extensions' => $uploadSetting['file_types']['video']['extensions']],
 
-                 'audio' => ['title' => 'Audio files', 'extensions' => $uploadSetting['file_types']['audio']['extensions']],
 
-                 'file'  => ['title' => 'Custom files', 'extensions' => $uploadSetting['file_types']['file']['extensions']]
 
-             ];
 
-             $arrData = $this->request->param();
 
-             if (empty($arrData["filetype"])) {
 
-                 $arrData["filetype"] = "image";
 
-             }
 
-             $fileType = $arrData["filetype"];
 
-             if (array_key_exists($arrData["filetype"], $arrFileTypes)) {
 
-                 $extensions                = $uploadSetting['file_types'][$arrData["filetype"]]['extensions'];
 
-                 $fileTypeUploadMaxFileSize = $uploadSetting['file_types'][$fileType]['upload_max_filesize'];
 
-             } else {
 
-                 $this->error('上传文件类型配置错误!');
 
-             }
 
-             View::share('filetype', $arrData["filetype"]);
 
-             View::share('extensions', $extensions);
 
-             View::share('upload_max_filesize', $fileTypeUploadMaxFileSize * 1024);
 
-             View::share('upload_max_filesize_mb', intval($fileTypeUploadMaxFileSize / 1024));
 
-             $maxFiles  = intval($uploadSetting['max_files']);
 
-             $maxFiles  = empty($maxFiles) ? 20 : $maxFiles;
 
-             $chunkSize = intval($uploadSetting['chunk_size']);
 
-             $chunkSize = empty($chunkSize) ? 512 : $chunkSize;
 
-             View::share('max_files', $arrData["multi"] ? $maxFiles : 1);
 
-             View::share('chunk_size', $chunkSize); //// 单位KB
 
-             View::share('multi', $arrData["multi"]);
 
-             View::share('app', $arrData["app"]);
 
-             $content = hook_one('fetch_upload_view');
 
-             $tabs = ['local', 'url', 'cloud'];
 
-             $tab = !empty($arrData['tab']) && in_array($arrData['tab'], $tabs) ? $arrData['tab'] : 'local';
 
-             if (!empty($content)) {
 
-                 $this->assign('has_cloud_storage', true);
 
-             }
 
-             if (!empty($content) && $tab == 'cloud') {
 
-                 return $content;
 
-             }
 
-             $tab = $tab == 'cloud' ? 'local' : $tab;
 
-             $this->assign('tab', $tab);
 
-             return $this->fetch(":webuploader");
 
-         }
 
-     }
 
-     /**
 
-      * webuploader 上传
 
-      */
 
-     public function webuploader(){
 
-         $minio_domain_url = 'http://43.239.167.134:9000';
 
-         if ($this->request->isPost()) {
 
-             
 
-             $configpri=getConfigPri();
 
-             /*$cloudtype=$configpri['cloudtype'];
 
-             if($cloudtype=="1"){ //七牛云存储
 
-                 $uploader = new Upload();
 
-                 $result = $uploader->upload();
 
-                 if ($result === false) {
 
-                     $this->error($uploader->getError());
 
-                 } else {
 
-                     $this->success("上传成功!", '', $result);
 
-                 }
 
-             }else{*/
 
-                 //其他云存储
 
-                 $result=adminUploadFiles($_FILES);
 
-                 if ($result!==false) {
 
-                     $data=array( 
 
-                         'filepath' => $result,
 
-                         'name'=> '',
 
-                         'id' => 'WU_FILE_0', 
 
- //                        'preview_url' => $configpri['aws_hosturl']."/".$result,
 
-                         'preview_url' => $minio_domain_url."/".$result,
 
-                         'url' => $result,
 
-                         'code'        =>0,
 
-                     );
 
-                     $this->success("上传成功!", '', $data);
 
-                 }else{
 
-                     $this->error(lang('上传失败,请重试'));
 
-                 }
 
- //            }
 
-         } else {
 
-             $uploadSetting = cmf_get_upload_setting();
 
-             $arrFileTypes = [
 
-                 'image' => ['title' => 'Image files', 'extensions' => $uploadSetting['file_types']['image']['extensions']],
 
-                 'video' => ['title' => 'Video files', 'extensions' => $uploadSetting['file_types']['video']['extensions']],
 
-                 'audio' => ['title' => 'Audio files', 'extensions' => $uploadSetting['file_types']['audio']['extensions']],
 
-                 'file'  => ['title' => 'Custom files', 'extensions' => $uploadSetting['file_types']['file']['extensions']]
 
-             ];
 
-             $arrData = $this->request->param();
 
-             if (empty($arrData["filetype"])) {
 
-                 $arrData["filetype"] = "image";
 
-             }
 
-             $fileType = $arrData["filetype"];
 
-             if (array_key_exists($arrData["filetype"], $arrFileTypes)) {
 
-                 $extensions                = $uploadSetting['file_types'][$arrData["filetype"]]['extensions'];
 
-                 $fileTypeUploadMaxFileSize = $uploadSetting['file_types'][$fileType]['upload_max_filesize'];
 
-             } else {
 
-                 $this->error('上传文件类型配置错误!');
 
-             }
 
-             View::share('filetype', $arrData["filetype"]);
 
-             View::share('extensions', $extensions);
 
-             View::share('upload_max_filesize', $fileTypeUploadMaxFileSize * 1024);
 
-             View::share('upload_max_filesize_mb', intval($fileTypeUploadMaxFileSize / 1024));
 
-             $maxFiles  = intval($uploadSetting['max_files']);
 
-             $maxFiles  = empty($maxFiles) ? 20 : $maxFiles;
 
-             $chunkSize = intval($uploadSetting['chunk_size']);
 
-             $chunkSize = empty($chunkSize) ? 512 : $chunkSize;
 
-             View::share('max_files', $arrData["multi"] ? $maxFiles : 1);
 
-             View::share('chunk_size', $chunkSize); //// 单位KB
 
-             View::share('multi', $arrData["multi"]);
 
-             View::share('app', $arrData["app"]);
 
-             $content = hook_one('fetch_upload_view');
 
-             $tabs = ['local', 'url', 'cloud'];
 
-             $tab = !empty($arrData['tab']) && in_array($arrData['tab'], $tabs) ? $arrData['tab'] : 'local';
 
-             if (!empty($content)) {
 
-                 $this->assign('has_cloud_storage', true);
 
-             }
 
-             if (!empty($content) && $tab == 'cloud') {
 
-                 return $content;
 
-             }
 
-             $tab = $tab == 'cloud' ? 'local' : $tab;
 
-             $this->assign('tab', $tab);
 
-             return $this->fetch(":webuploader");
 
-         }
 
-     }
 
- }
 
 
  |