|
...
|
...
|
@@ -227,16 +227,17 @@ class NewsLogic extends BaseLogic |
|
|
|
if ($decodedData === false) {
|
|
|
|
continue; // 如果解码失败,则跳过
|
|
|
|
}
|
|
|
|
return $decodedData;
|
|
|
|
// 设置文件名
|
|
|
|
$outputFile = 'images/' . uniqid() . '.' . $imageType;
|
|
|
|
$filePath = __DIR__ . '/' . $outputFile;
|
|
|
|
// 保存图片到服务器
|
|
|
|
if (file_put_contents($filePath, $decodedData)) {
|
|
|
|
// 生成图片URL
|
|
|
|
$imageUrl = 'http://your-domain.com/' . $outputFile;
|
|
|
|
// 替换原字符串中的Base64流为图片链接
|
|
|
|
$outputString = str_replace($base64String, $imageUrl, $outputString);
|
|
|
|
}
|
|
|
|
// if (file_put_contents($filePath, $decodedData)) {
|
|
|
|
// // 生成图片URL
|
|
|
|
// $imageUrl = 'http://your-domain.com/' . $outputFile;
|
|
|
|
// // 替换原字符串中的Base64流为图片链接
|
|
|
|
// $outputString = str_replace($base64String, $imageUrl, $outputString);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $outputString;
|
|
...
|
...
|
@@ -252,7 +253,7 @@ class NewsLogic extends BaseLogic |
|
|
|
$this->uploads = config('upload.default_image');
|
|
|
|
$path = $this->uploads['path_b'].'/'.($this->user['project_id'] ?? 1618).'/image_news/'.date('Y-m');
|
|
|
|
$cosService = new CosService();
|
|
|
|
$fileName = md5(uniqid() . '_' . time() . '.' . ($this->user['project_id'] ?? 1618).rand(1,10000));
|
|
|
|
$fileName = md5(uniqid() . '_' . time() . '.' . ($this->user['project_id'] ?? 1618).rand(1,10000)).'png';
|
|
|
|
return $cosService->uploadFile($files,$path,$fileName);
|
|
|
|
}
|
|
|
|
/**
|
...
|
...
|
|