xielin 5 anni fa
parent
commit
cdbbd4aaeb
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      app/Http/Controllers/UploadController.php

+ 8 - 6
app/Http/Controllers/UploadController.php

@@ -25,15 +25,16 @@ class UploadController extends Controller
                 $width = Image::make($filePath)->width();
                 $height = Image::make($filePath)->height();
                 //要保存的文件名 时间+扩展名
-                $filename = time() . '_' . uniqid() . '.' . $kuoname . '?' . $width . '_' . $height;
+                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+                $fileurl = $filename . '?' . $width . '_' . $height;
             } else {
                 //要保存的文件名 时间+扩展名
-                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+                $fileurl = $filename = time() . '_' . uniqid() . '.' . $kuoname;
             }
             $imageUrl = Storage::put($path . $filename, file_get_contents($filePath));
             Log::debug('upload_url:' . $imageUrl);
             if ($imageUrl) {
-                return $this->jsonSuccess(['url' => config('customer.chxq_oss_url') . $path . $filename]);
+                return $this->jsonSuccess(['url' => config('customer.chxq_oss_url') . $path . $fileurl]);
             } else {
                 return $this->jsonError('图片上传失败,请重试');
             }
@@ -57,14 +58,15 @@ class UploadController extends Controller
                 $width = Image::make($filePath)->width();
                 $height = Image::make($filePath)->height();
                 //要保存的文件名 时间+扩展名
-                $filename = time() . '_' . uniqid() . '.' . $kuoname . '?' . $width . '_' . $height;
+                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+                $fileurl = $filename . '?' . $width . '_' . $height;
             } else {
                 //要保存的文件名 时间+扩展名
-                $filename = time() . '_' . uniqid() . '.' . $kuoname;
+                $fileurl = $filename = time() . '_' . uniqid() . '.' . $kuoname;
             }
             $imageUrl = Storage::put($path . $filename, file_get_contents($filePath));
             if ($imageUrl) {
-                array_push($urls, config('customer.chxq_oss_url') . $path . $filename);
+                array_push($urls, config('customer.chxq_oss_url') . $path . $fileurl);
             } else {
                 Log::debug('文件上传失败。' . $filename);
             }