currently i'm working on a application where user can upload a file to my system. I've followed everything from the doc provided by laravel, below is my code.
In my HTML, my image input
<input type="file" name="thread_image">
In my controller, i have done the validation as below
$validator = Validator::make($request::all(),
[
'thread_title' => 'required|max:100',
'thread_remark' => 'max:1000',
'thread_image' => 'required|mimes:jpeg,jpg,png',
],
[
'thread_title.required' => 'Please fill in thread title.',
'thread_title.max' => 'Thread title has exceeded 100 characters.',
'thread_remark.max' => 'Thread remark has exceeded 1000 characters.',
'thread_image.required' => 'Please select an image to post this thread.',
'thread_image.mimes' => 'Please select an correct image with the format of jpeg,jpg,png.',
]);
if ($validator->fails()) {
return Redirect::back()
->withErrors($validator)
->withInput();
}
Other input have validated correctly, exact the image. Am i doing anything wrong? I've try to upload jpeg,jpg and png, none of them have pass the validation.