Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NikhilLVL's avatar

Call to a member function getClientOriginalName() on null

Part in my blade:

@csrf Upload your image:

Here's the code in my controller:

    $file = $request->file('image');
    $filename = $file->getClientOriginalName();
    $file->move(public_path().'uploads/images',$filename);
    $data->image=$filename;
0 likes
4 replies
MichalOravec's avatar

Do you have enctype="multipart/form-data" in your form?

<form action="#" method="POST" enctype="multipart/form-data">
ashir_ali_butt's avatar

there are two things that are wrong:

  1. May you are not use attribute in form tag <form action="#" method="POST" enctype="multipart/form-data">
  2. May in your form input type file you set wrong name Example: In view.blade.php you create <input type="file" name="photo" id="photo" /> But you are fetching by $request->file('image'); So there are mistake name of the file so you need to correct this like $request->file(‘photo’) So check all cases that i mentioned I hope you solve your problem easily
Snapey's avatar

part in my blade

Please format your code by putting 3 backticks ``` on a line before and after each code block

Please or to participate in this conversation.