48 lines
909 B
PHP
48 lines
909 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api;
|
||
|
|
|
||
|
|
use App\BaseApp\BaseController;
|
||
|
|
use App\Service\common\UploadService;
|
||
|
|
use Illuminate\Http\JsonResponse;
|
||
|
|
|
||
|
|
class UploadController extends BaseController
|
||
|
|
{
|
||
|
|
//
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
parent::__construct();
|
||
|
|
$this->service = UploadService::getInstance();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 图片上传
|
||
|
|
* @Method POST
|
||
|
|
* @return JsonResponse
|
||
|
|
* @throws \Exception
|
||
|
|
*/
|
||
|
|
public function image()
|
||
|
|
{
|
||
|
|
$file = request()->file('file');
|
||
|
|
return jok(
|
||
|
|
$this->service->uploadImage($file),
|
||
|
|
'上传成功'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 视频上传
|
||
|
|
* @Method POST
|
||
|
|
* @return JsonResponse
|
||
|
|
*/
|
||
|
|
public function video()
|
||
|
|
{
|
||
|
|
$file = request()->file('file');
|
||
|
|
return jok(
|
||
|
|
$this->service->uploadVideo($file),
|
||
|
|
'上传成功'
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|