|
|
@@ -0,0 +1,35 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\controller\admin;
|
|
|
+
|
|
|
+use app\extra\basic\Base;
|
|
|
+use app\extra\tools\UploadExtend;
|
|
|
+use app\middleware\AuthMiddleware;
|
|
|
+use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
+use LinFly\Annotation\Attributes\Route\Middleware;
|
|
|
+use LinFly\Annotation\Attributes\Route\PostMapping;
|
|
|
+use support\Request;
|
|
|
+use support\Response;
|
|
|
+
|
|
|
+
|
|
|
+#[Controller("/api/upload"),Middleware(AuthMiddleware::class)]
|
|
|
+class Upload extends Base
|
|
|
+{
|
|
|
+
|
|
|
+ #[PostMapping("data")]
|
|
|
+ public function upload2image(Request $request): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $resp = UploadExtend::uploadFile();
|
|
|
+ if (!isset($resp[0]['url'])) return errorTrans(40010);
|
|
|
+ return successTrans("success.data",[
|
|
|
+ "fileName" => $resp[0]['origin_name'],
|
|
|
+ "src" => $resp[0]['url'],
|
|
|
+ ],200);
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|