I get this error after submitting the form. Here’s the controller code.
The error appears to be in the validate() part.
public function store(Request $request) {
$video = new Video();
$request->validate([
'title' => 'required|max:68',
'description' => 'required|max:256',
'image' => 'image|mimes:jpeg,png,jpg,webp|max:2048',
'video' => 'video|mimes:m4v,avi,flv,mp4,mov',
]);
if($request->image) {
$title = uniqid().'.'.$request->image->extension();
$request->image->move(public_path('video/images'), $title);
$video->image = $title;
}
if($request->video) {
$title = uniqid().'.'.$request->video->extension();
$request->video->move(public_path('video/videos'), $title);
$video->video = $title;
}
$video->title = $request->title;
$video->description = $request->description;
$video->save();
return redirect()->route('videos.list')->with('Success','video created successfully!');
}
Thanks in advance
I tried different things but I still need figuring this out
2
Answers
Change
to
Docs: https://laravel.com/docs/9.x/validation#rule-mimetypes
laravel doesn’t support video attribute
Would use this version