新增上传
This commit is contained in:
parent
08fb8b3397
commit
f2affda157
59
catch/wechat/controller/Upload.php
Normal file
59
catch/wechat/controller/Upload.php
Normal 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']));
|
||||
}
|
||||
}
|
@ -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');
|
||||
|
||||
// 消息
|
||||
|
Loading…
x
Reference in New Issue
Block a user