1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-20 11:03:01 +08:00
2022-08-01 16:43:55 +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 = [
'src' => $service->getImageUrl($file->path),
'title' => $file->name,
];
return $this->jsonSuccess(['data' => $data]);
}
}