From ca2619ae08e067ca7b35dfd0820babfaddba00cb Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 14 May 2024 14:47:01 +0700 Subject: [PATCH] fix: fixed getSize in multiple upload --- app/Http/Controllers/ImageController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ImageController.php b/app/Http/Controllers/ImageController.php index af18b45..1e3c194 100644 --- a/app/Http/Controllers/ImageController.php +++ b/app/Http/Controllers/ImageController.php @@ -75,12 +75,12 @@ class ImageController extends Controller } else { DB::rollBack(); unlink($destinationPath['pathImage'].$name); - return response()->json(['status' => 'failed','message' => 'image upload is failed! pertama' ,'code' => 400], 400); + return response()->json(['status' => 'failed','message' => 'image upload is failed!' ,'code' => 400], 400); } } else { DB::rollBack(); - return response()->json(['status'=>'failed','message'=>'image upload is failed! kedua','code'=>400], 400); + return response()->json(['status'=>'failed','message'=>'image upload is failed!','code'=>400], 400); } } else { DB::rollBack(); @@ -105,7 +105,10 @@ class ImageController extends Controller $company = Company::where('company_name', $request->company_name)->first(); if($company) { $totalSize = 0; - $sizeFile = $dokumen->getSize(); + $sizeFile = 0; + foreach ($dokumen as $file) { + $sizeFile += $file->getSize(); + } $destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); $folderPath = $destinationPath['pathImage']; @@ -114,7 +117,6 @@ class ImageController extends Controller } $files = scandir($folderPath); - $totalSize = 0; foreach ($files as $file) { if (is_file($folderPath . '/' . $file)) {