I'm trying to upload an image though everytime I submit it's returning that the store() on null error. I've set the form to enctype="multipart/form-data" which hasn't helped.
Can anyone point me in the right direction?
Thanks.
Function inside the controller
public function store(Request $request){
$file = $request->file('imgUpload1')->store('images');
return back();
}
Form below:
<form action="/imgupload" method="POST" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group">
<label for="imgUpload1">File input</label>
<input type="file" id="imgUpload1">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
I had the same issue what I did to fix is in the opening form tag add enctype="multipart/form-data"
that should fix it. Without it laravel would not understand the file.
like:
<form method="POST" enctype="multipart/form-data" name="formName">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With