From 2cf2c19d910721695148c1f67319aba50782fc4f Mon Sep 17 00:00:00 2001 From: lq Date: Tue, 17 Jun 2025 15:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ImageController.php | 1 - app/Service/ImageService.php | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index 197b2f8b..7280611f 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -14,7 +14,6 @@ class ImageController extends Controller $image = request()->file('image'); $pid = request()->file('pid'); - dd($image); return new ImageService()->processImage($image, $pid); } } diff --git a/app/Service/ImageService.php b/app/Service/ImageService.php index c45a96a9..51188a3b 100644 --- a/app/Service/ImageService.php +++ b/app/Service/ImageService.php @@ -17,9 +17,8 @@ class ImageService */ public function processImage($imageFile, $pid = 1) { - return $imageFile; // 1. 保存原始图片 - $originalPath = $this->storeOriginalImage(file_get_contents($imageFile)); + $originalPath = $this->storeOriginalImage($imageFile); // 2. 无损压缩图片 $compressedPath = $this->compressToWebp($originalPath); @@ -48,7 +47,7 @@ class ImageService protected function storeOriginalImage($imageFile) { $path = 'images/original/cc_'. date('Ymdhis') . Str::random(40) . '.' . $imageFile->getClientOriginalExtension(); - Storage::put($path, $imageFile); + Storage::put($path, file_get_contents($imageFile)); return $path; }