作者 lyh

hx

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