123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace app\adminapi\controller\sys;
- use app\service\admin\upload\UploadService;
- use core\base\BaseAdminController;
- use think\Response;
- class Ueditor extends BaseAdminController
- {
- public function getConfig() {
- return Response::create([
- "state" => "SUCCESS",
- "imageActionName" => "image",
-
- "imageFieldName" => "file",
-
- "imageMaxSize" => 10485760,
-
- "imageAllowFiles" => [".jpg", ".png", ".jpeg"],
-
- "imageCompressEnable" => true,
-
- "imageCompressBorder" => 5000,
-
- "imageInsertAlign" => "none",
-
- "imageUrlPrefix" => url('/', domain: true)->buildUrl(),
-
- "scrawlActionName" => "crawl",
-
- "scrawlFieldName" => "file",
-
- "scrawlMaxSize" => 10485760,
-
- "scrawlUrlPrefix" => "",
-
- "scrawlInsertAlign" => "none",
-
- "snapscreenActionName" => "snap",
-
- "snapscreenUrlPrefix" => "",
-
- "snapscreenInsertAlign" => "none",
-
- "catcherLocalDomain" => array("127.0.0.1", "localhost"),
-
- "catcherActionName" => "catch",
-
- "catcherFieldName" => "source",
-
- "catcherUrlPrefix" => "",
-
- "catcherMaxSize" => 10485760,
-
- "catcherAllowFiles" => [".jpg", ".png", ".jpeg"],
-
- "videoActionName" => "video",
-
- "videoFieldName" => "file",
-
- "videoUrlPrefix" => url('/', domain: true)->buildUrl(),
-
- "videoMaxSize" => 104857600,
-
- "videoAllowFiles" => [".mp4"],
-
- "fileActionName" => "file",
-
- "fileFieldName" => "file",
-
- "fileUrlPrefix" => "",
-
- "fileMaxSize" => 104857600,
-
- "fileAllowFiles" => [".zip", ".pdf", ".doc"],
-
- "imageManagerActionName" => "listImage",
-
- "imageManagerListSize" => 20,
-
- "imageManagerUrlPrefix" => "",
-
- "imageManagerInsertAlign" => "none",
-
- "imageManagerAllowFiles" => [".jpg", ".png", ".jpeg"],
-
- "fileManagerActionName" => "listFile",
-
- "fileManagerUrlPrefix" => "",
-
- "fileManagerListSize" => 20,
-
- "fileManagerAllowFiles" => [".zip", ".pdf", ".doc"],
-
- "formulaConfig" => [
-
- "imageUrlTemplate" => url('/', domain: true)->buildUrl() . "{}"
- ]
- ], 'json', 200);
- }
- public function upload() {
- $data = $this->request->params([
- ['action', ''],
- ['file', 'file'],
- ]);
- $upload_service = new UploadService();
- switch ($data['action']) {
- case 'image':
- $upload_res = $upload_service->image($data['file']);
- return Response::create([
- 'state' => 'SUCCESS',
- 'url' => $upload_res['url'],
- 'title' => $upload_res['url'],
- 'original' => $upload_res['url'],
- ], 'json', 200);
- break;
- case 'video':
- $upload_res = $upload_service->video($data['file']);
- return Response::create([
- 'state' => 'SUCCESS',
- 'url' => $upload_res['url'],
- 'title' => $upload_res['url'],
- 'original' => $upload_res['url'],
- ], 'json', 200);
- break;
- }
- }
- }
|