|
|
@@ -3306,7 +3306,7 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
if (empty($up_img)) {
|
|
|
return Result::error("修改失败", 0);
|
|
|
}
|
|
|
- return Result::success($up_img);
|
|
|
+ return Result::success($img);
|
|
|
// 将字节转换为更友好的单位
|
|
|
// $friendlySize = $this->formatFileSize($size);
|
|
|
// $data['img_size'] = $friendlySize;
|
|
|
@@ -3449,6 +3449,22 @@ class WebsiteService implements WebsiteServiceInterface
|
|
|
{
|
|
|
$id = $data['id'];
|
|
|
unset($data['id']);
|
|
|
+ if(isset($data['img_url']) && !empty($data['img_url'])){
|
|
|
+ $url = $data['img_url'];
|
|
|
+ // 1. 分割路径部分(以 / 为分隔符)
|
|
|
+ $pathSegments = explode('/', parse_url($url, PHP_URL_PATH));
|
|
|
+
|
|
|
+ // 2. 取最后一个元素作为文件名
|
|
|
+ $fileName = end($pathSegments); // 1743041040714597.jpg
|
|
|
+
|
|
|
+ // 3. 分割文件名获取扩展名
|
|
|
+ $fileParts = explode('.', $fileName);
|
|
|
+ $fileType = end($fileParts); // jpg
|
|
|
+ $data['img_type'] = $fileType;
|
|
|
+ $data['name'] = $fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$result = WebsiteImg::where('id', $id)->update($data);
|
|
|
if (empty($result)) {
|
|
|
return Result::error("修改失败", 0);
|