1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-21 03:17:05 +08:00
xiaochong0302 00cb8bf963 1.拆解migration创建表脚本
2.增加post方式传递csrf_token
3.优化storage上传
2024-02-26 09:56:51 +08:00

40 lines
839 B
PHP

<?php
/**
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.koogua.com
*/
namespace App\Http\Api\Controllers;
use App\Services\MyStorage as StorageService;
/**
* @RoutePrefix("/api/upload")
*/
class UploadController extends Controller
{
/**
* @Post("/avatar/img", name="api.upload.avatar_img")
*/
public function uploadAvatarImageAction()
{
$service = new StorageService();
$file = $service->uploadAvatarImage();
if (!$file) {
return $this->jsonError(['msg' => '上传文件失败']);
}
$data = [
'url' => $service->getImageUrl($file->path),
'title' => $file->name,
];
return $this->jsonSuccess(['data' => $data]);
}
}