getAuthUser(); $validator = new AppValidator(); $validator->checkAuthUser($authUser->id); } /** * @Post("/avatar/img", name="home.upload.avatar_img") */ public function uploadAvatarImageAction() { $service = new StorageService(); $file = $service->uploadAvatarImage(); if (!$file) { return $this->jsonError(['msg' => '上传文件失败']); } $data = [ 'url' => $service->getImageUrl($file->path), 'title' => $file->name, ]; return $this->jsonSuccess(['data' => $data]); } /** * @Post("/editor/img", name="home.upload.editor_img") */ public function uploadEditorImageAction() { $service = new StorageService(); $file = $service->uploadContentImage(); if (!$file) { return $this->jsonError([ 'message' => '上传图片失败', 'error' => 1, ]); } return $this->jsonSuccess([ 'url' => $service->getImageUrl($file->path), 'error' => 0, ]); } }