新增上传

This commit is contained in:
JaguarJack 2020-06-29 20:02:33 +08:00
parent 08fb8b3397
commit f2affda157
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,59 @@
<?php
// +----------------------------------------------------------------------
// | CatchAdmin [Just Like ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2020 http://catchadmin.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
// +----------------------------------------------------------------------
// | Author: JaguarJack [ njphper@gmail.com ]
// +----------------------------------------------------------------------
namespace catchAdmin\wechat\controller;
use catchAdmin\system\model\Attachments;
use catcher\base\CatchController;
use catcher\base\CatchRequest;
use catcher\CatchResponse;
use catcher\CatchUpload;
class Upload extends CatchController
{
protected $attachment;
public function __construct(Attachments $attachment)
{
$this->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']));
}
}

View File

@ -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');
// 消息