How to bulk upload images in Laravel

Published

This is the code that i use now, this works for uploading single images, but i want the option to choose multiple images at the same time and upload them to the s3 bucket.

public function create() {
    return view(view: 'images.create');
}

public function store(Request $request) {
    $path = $request -> file(key: 'image') -> store(path: 'images', options: 's3');

    $image = Image::create([
    'filename' => basename($path),
    'url' => Storage::disk(name: 's3') -> url($path)
    ]);

    return $image;
}

public function show(Image $image) {
    return $image -> url;
}

I have been looking into the answer to this question: Uploading multiple files to Amazon S3 from PHP

But struggle to understand and how to implement it into my own code.

Source: Laravel

Published
Categorised as laravel, php Tagged ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq