2020-06-29 20:02:33 +08:00

59 lines
1.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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']));
}
}