how to update multiple images in laravel 9

In previous section we will see how to upload multiple image in laravel 9. For this section we will see how to edit update multiple image in laravel 9. Before we start you need to read below blog.

Laravel 9 Upload Multiple Images Tutorial Example

Now Add Edit and Update method.


public function edit(Project $project)
    return view('projects.edit', compact('project'));

    * Update the specified resource in storage.
    * @param  \Illuminate\Http\Request  $request
    * @param  \App\Models\Project  $project
    * @return \Illuminate\Http\Response
public function update(Request $request, Project $project)
    $data = $request->validate([
        'name' => 'required|string|max:255',
        'images' => 'nullable|array'
    if ($request->hasFile('images')) {
        $images = [];
        foreach ($data['images'] as $image) {
            $fileName = uniqid() . '.' . $image->getClientOriginalExtension();
            $image_path =  $image->storeAs('images', $fileName, 'public');
            array_push($images, $image_path);
            $data['images'] = $images;
    return redirect()->route('projects.index');


    <x-slot name="header">
        <h2 class="text-xl font-semibold leading-tight text-gray-800">
            {{ __('Project Edit') }}

    <div class="py-12">
        <div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
            <div class="overflow-hidden bg-white shadow-sm sm:rounded-lg">
                <div class="p-6 bg-white border-b border-gray-200">
                    <form method="POST" action="{{ route('projects.update',$project->id) }}"
                        <div class="mb-6">
                            <label class="block">
                                <span class="text-gray-700">Name</span>
                                <input type="text" name="name"
                                    class="block w-full @error('name') border-red-500 @enderror mt-1 rounded-md"
                                    placeholder="" value="{{old('name',$project->name)}}" />
                            <div class="text-sm text-red-600">{{ $message }}</div>
                        <div class="mb-4">
                            <label class="block">
                                <span class="text-gray-700">Images</span>
                                <input type="file" name="images[]" class="block w-full mt-1 rounded-md" placeholder=""
                                    multiple />
                            <div class="text-sm text-red-600">{{ $message }}</div>
                        <div class="flex gap-4 mb-4">
                            @foreach($project->images as $image)
                            <img src="{{ asset('/storage/' . $image) }}" alt="multiple show"
                                class="w-20 h-20 border border-blue-600">
                        <button type="submit"
                            class="text-white bg-blue-600  rounded text-sm px-5 py-2.5">Update</button>


index.blade.php file to show images

laravel 9 show image before update

laravel 9 show image before update

edit.blade.php file to to update images.

laravel 9 edit images

laravel 9 edit images

After update multiple images.

laravel update multiple images

laravel update multiple images

Read Also

Laravel 9 Upload Multiple Image Using Spatie Media Library

How To Upload Multiple Images In Laravel 9 With Intervention

How to update multiple images in laravel 9

Upload Images with Spatie Media Library in Laravel 9