mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-20 11:03:01 +08:00
50 lines
973 B
PHP
50 lines
973 B
PHP
<?php
|
|
|
|
|
|
namespace App\Http\Home\Controllers;
|
|
|
|
use App\Services\MyStorage as StorageService;
|
|
|
|
/**
|
|
* @RoutePrefix("/upload")
|
|
*/
|
|
class UploadController extends Controller
|
|
{
|
|
|
|
/**
|
|
* @Post("/avatar/img", name="home.upload.avatar_img")
|
|
*/
|
|
public function uploadAvatarImageAction()
|
|
{
|
|
$service = new StorageService();
|
|
|
|
$file = $service->uploadAvatarImage();
|
|
|
|
if ($file) {
|
|
return $this->jsonSuccess([
|
|
'data' => [
|
|
'src' => $service->getImageUrl($file->path),
|
|
'title' => $file->name,
|
|
]
|
|
]);
|
|
} else {
|
|
return $this->jsonError(['msg' => '上传文件失败']);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @Post("/im/img", name="home.upload.im_img")
|
|
*/
|
|
public function uploadImImageAction()
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @Post("/im/file", name="home.upload.im_file")
|
|
*/
|
|
public function uploadImFileAction()
|
|
{
|
|
|
|
}
|
|
|
|
} |