I build a Laravel Application. I have a file-upload-form where users can upload images or videos.
I made The following settings in th php.ini file
upload_max_filesize = 32M
post_max_size = 32M
My validation rules:
$mime = $request->file("file")->getClientOriginalExtension();
if ($mime == "png" || $mime == "jpg" || $mime == "jpeg") {
$rules["file"] = "required|file|mimes:jpeg,jpg,png|max:1024";
} elseif ($mime == "mp4" || $mime == "webm") {
$rules["file"] = "required|file|mimes:webm,mp4|max:32768";
}
I handle the upload with
$request->file("file")->store("uploads");
Following Scenarios:
- When I upload a image everything works well
- When I upload a really small video (500kb) everything works well
- When I upload a 5MB video I get the following ErrorMessage
The file failed to upload.