Abhi324's avatar

Laravel forms - Image upload returning null

Hi , i'm having an issue with image upload . I can select the file , then it automatically submits the form . However when i try to access the image in my controller - its getting null.

<form class="form-horizontal" role="form" name="upload-form" method="POST" files=true action="{{ url('/upload') }}">
    <input type="file"  name="image"  onchange="this.form.submit()"/>
<form>

Question 1 , should i use

files=true or files="true" ? (tried both - same error)

In my controller :

$file = $request->file('image');
$img_ex = $file->getClientOriginalExtension(); 

getting error :

Call to a member function getClientOriginalExtension() on null

0 likes
1 reply
Abhi324's avatar
Abhi324
OP
Best Answer
Level 1

Fixed using

enctype="multipart/form-data"

Please or to participate in this conversation.