'im trying to upload multiple images but when I push this code on server it gives me the hashName error

im trying to upload multiple images but when I push this code on server it gives me the hashName error.

This Is the error:

Call to a member function hashName() on null

HTML code:

<form action="{{ route('products.store') }}" method="post" enctype="multipart/form-data">
        <!-- Add CSRF Token -->
        @csrf
    <div class="form-group">
        <label>Product Name</label>
        <p> le nom du theme <input type="text" class="form-control" name="name" required></p>
        </br>
        <p>la description du theme<input type="text" class="form-control" name="description" required</p>
       <div class="form-group">
       <input type="file" name="image" required>
       <input type="file" name="image2" required>
       <input type="file" name="image3" required>
       <input type="text" class="form-control" name="prix" required>
       <input type="text" class="form-control" name="nb_download" required>
       <input type="file" name="file" required>
       <button type="submit">Submit</button>
    </div>
</form>

the route:

route::resource('products','App\http\controllers\TemplatesController');

templatesController (store function):

 public function store(Request $request)
    {
            
            $templates = new templates([
                "name" => $request->get('name'),
                "description"=>$request->get('description'),
                "image_path"=>$request->image1->hashName(),
                "image_path2"=>$request->image2->hashName(),
                "image_path3"=>$request->image3->hashName(),
                "prix"=>$request->get('prix'),
                "file_path" => $request->file->hashName(),
                "nb_download"=>$request->get('nb_download')
            ]);

            $request->image1->move(public_path('images'));
            $request->image2->move(public_path('images'));
            $request->image3->move(public_path('images'));


            $templates->save(); 
            
        

        return view('products.create');

    }


Solution 1:[1]

it was a typo! the input type name was "image" not "image1". –

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gazdallah Amira