1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-18 01:58:25 +08:00
2020-03-16 15:33:36 +08:00

48 lines
1.1 KiB
PHP

<?php
namespace App\Http\Admin\Controllers;
use App\Services\Storage as StorageService;
/**
* @RoutePrefix("/admin/upload")
*/
class UploadController extends Controller
{
/**
* @Post("/cover/img", name="admin.upload.cover.img")
*/
public function uploadCoverImageAction()
{
$storageService = new StorageService();
$key = $storageService->uploadCoverImage();
$url = $storageService->getCiImageUrl($key);
if ($url) {
return $this->ajaxSuccess(['data' => ['src' => $url, 'title' => '']]);
} else {
return $this->ajaxError(['msg' => '上传文件失败']);
}
}
/**
* @Post("/content/img", name="admin.upload.content.img")
*/
public function uploadContentImageAction()
{
$storageService = new StorageService();
$url = $storageService->uploadContentImage();
if ($url) {
return $this->ajaxSuccess(['data' => ['src' => $url, 'title' => '']]);
} else {
return $this->ajaxError(['msg' => '上传文件失败']);
}
}
}