diff --git a/catch/wechat/controller/Upload.php b/catch/wechat/controller/Upload.php new file mode 100644 index 0000000..0852c9e --- /dev/null +++ b/catch/wechat/controller/Upload.php @@ -0,0 +1,59 @@ +attachment = $attachment; + } + + /** + * image upload + * + * @time 2020年01月25日 + * @param CatchRequest $request + * @param CatchUpload $upload + * @return \think\response\Json + * @throws \Exception + */ + public function image(CatchRequest $request, CatchUpload $upload): \think\response\Json + { + $images = $request->file(); + + return CatchResponse::success($upload->setDriver(CatchUpload::LOCAL)->checkImages($images)->multiUpload($images['image'])); + } + + /** + * file upload + * + * @time 2020年01月25日 + * @param CatchRequest $request + * @param CatchUpload $upload + * @return \think\response\Json + * @throws \Exception + */ + public function file(CatchRequest $request, CatchUpload $upload): \think\response\Json + { + $files = $request->file(); + + return CatchResponse::success($upload->setDriver(CatchUpload::LOCAL)->checkFiles($files)->multiUpload($files['file'])); + } +} \ No newline at end of file diff --git a/catch/wechat/route.php b/catch/wechat/route.php index e937788..e3e61ad 100644 --- a/catch/wechat/route.php +++ b/catch/wechat/route.php @@ -36,6 +36,11 @@ $router->group('wechat', function () use ($router){ $router->group('official/reply', function () use ($router){ $router->resource('', '\catchAdmin\wechat\controller\Reply'); }); + // 微信回复管理 + $router->group('official/upload', function () use ($router){ + $router->post('/image', '\catchAdmin\wechat\controller\Upload@image'); + $router->post('/file', '\catchAdmin\wechat\controller\Upload@file'); + }); })->middleware('auth'); // 消息