I have added a form added image file upload and validated it, the file upload accepting only .png file. When I choose jpg,jpeg or other formats throws error message field must be an image.
Laravel version Version 5.8.38
My controller Method
public function store() {
$data = request()->validate([
'caption' => 'required',
'image' => 'required | image'
]);
Post::create($data);
}
My View
<form action="/p" enctype="multipart/form-data" method="POST">
@csrf
<div class="row">
<label for="image" class="col-md-4 col-form-label">Post Image</label>
<input type="file" class="form-control-file" id="image" name="image">
@error('image')
<strong style="color: #e3342f;font-size:80%">{{ $message }}</strong>
@enderror
</div>
</form>