Browse Source

fix: fixed getSize in multiple upload

pull/1/head
wahyun 6 months ago
parent
commit
ca2619ae08
  1. 10
      app/Http/Controllers/ImageController.php

10
app/Http/Controllers/ImageController.php

@ -75,12 +75,12 @@ class ImageController extends Controller
} else { } else {
DB::rollBack(); DB::rollBack();
unlink($destinationPath['pathImage'].$name); 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 { } else {
DB::rollBack(); 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 { } else {
DB::rollBack(); DB::rollBack();
@ -105,7 +105,10 @@ class ImageController extends Controller
$company = Company::where('company_name', $request->company_name)->first(); $company = Company::where('company_name', $request->company_name)->first();
if($company) { if($company) {
$totalSize = 0; $totalSize = 0;
$sizeFile = $dokumen->getSize(); $sizeFile = 0;
foreach ($dokumen as $file) {
$sizeFile += $file->getSize();
}
$destinationPath = $this->setCustomeDirectoryUpload($company['company_name']); $destinationPath = $this->setCustomeDirectoryUpload($company['company_name']);
$folderPath = $destinationPath['pathImage']; $folderPath = $destinationPath['pathImage'];
@ -114,7 +117,6 @@ class ImageController extends Controller
} }
$files = scandir($folderPath); $files = scandir($folderPath);
$totalSize = 0;
foreach ($files as $file) { foreach ($files as $file) {
if (is_file($folderPath . '/' . $file)) { if (is_file($folderPath . '/' . $file)) {

Loading…
Cancel
Save