mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-25 04:07:17 +08:00
修正内容图片上传问题
This commit is contained in:
parent
fbcc721828
commit
93ec72faf6
@ -99,43 +99,16 @@ class UploadController extends Controller
|
|||||||
$file = $service->uploadContentImage();
|
$file = $service->uploadContentImage();
|
||||||
|
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return $this->jsonError(['msg' => '上传文件失败']);
|
return $this->jsonError([
|
||||||
|
'message' => '上传图片失败',
|
||||||
|
'error' => 1,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
return $this->jsonSuccess([
|
||||||
'src' => $service->getImageUrl($file->path),
|
'url' => $service->getImageUrl($file->path),
|
||||||
'title' => $file->name,
|
'error' => 0,
|
||||||
];
|
]);
|
||||||
|
|
||||||
return $this->jsonSuccess(['data' => $data]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Post("/remote/img", name="admin.upload.remote_img")
|
|
||||||
*/
|
|
||||||
public function uploadRemoteImageAction()
|
|
||||||
{
|
|
||||||
$originalUrl = $this->request->getPost('url', ['trim', 'string']);
|
|
||||||
|
|
||||||
$service = new StorageService();
|
|
||||||
|
|
||||||
$file = $service->uploadRemoteImage($originalUrl);
|
|
||||||
|
|
||||||
$newUrl = $originalUrl;
|
|
||||||
|
|
||||||
if ($file) {
|
|
||||||
$newUrl = $service->getImageUrl($file->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑器要求返回的数据结构
|
|
||||||
*/
|
|
||||||
$data = [
|
|
||||||
'url' => $newUrl,
|
|
||||||
'originalURL' => $originalUrl,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->jsonSuccess(['data' => $data]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,43 +56,16 @@ class UploadController extends Controller
|
|||||||
$file = $service->uploadContentImage();
|
$file = $service->uploadContentImage();
|
||||||
|
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return $this->jsonError(['msg' => '上传文件失败']);
|
return $this->jsonError([
|
||||||
|
'message' => '上传图片失败',
|
||||||
|
'error' => 1,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
return $this->jsonSuccess([
|
||||||
'src' => $service->getImageUrl($file->path),
|
'url' => $service->getImageUrl($file->path),
|
||||||
'title' => $file->name,
|
'error' => 0,
|
||||||
];
|
]);
|
||||||
|
|
||||||
return $this->jsonSuccess(['data' => $data]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Post("/remote/img", name="home.upload.remote_img")
|
|
||||||
*/
|
|
||||||
public function uploadRemoteImageAction()
|
|
||||||
{
|
|
||||||
$originalUrl = $this->request->getPost('url', ['trim', 'string']);
|
|
||||||
|
|
||||||
$service = new StorageService();
|
|
||||||
|
|
||||||
$file = $service->uploadRemoteImage($originalUrl);
|
|
||||||
|
|
||||||
$newUrl = $originalUrl;
|
|
||||||
|
|
||||||
if ($file) {
|
|
||||||
$newUrl = $service->getImageUrl($file->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编辑器要求返回的数据结构
|
|
||||||
*/
|
|
||||||
$data = [
|
|
||||||
'url' => $newUrl,
|
|
||||||
'originalURL' => $originalUrl,
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->jsonSuccess(['data' => $data]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user