__('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 = $s3Folder . '/' . $filename; // Save the file to S3 Storage::disk('s3')->put($filePath, $image); // Return the URL of the uploaded image return Storage::disk('s3')->url($filePath); } }