__('general.image'), 'values' => 'jpg, jpeg, png, gif'])); } $image = base64_decode($base64Image); if ($image === false) { throw new Exception('Base64 decode failed'); } } else { throw new Exception('Invalid base64 image format'); } // Generate a unique filename $filename = Str::random(20).'.'.$type; // Define the full path where the file will be stored $filePath = $folder.'/'.$filename; Storage::put($filePath, $image); return $filePath; } }