这就是在laravel中验证视频文件的方法吗?
$validator = Validator::make(Input::all(),
array(
'file' => 'mimes:mp4,mov,ogg | max:20000'
)
);
because even if the file uploaded is a mov type, it will return that the file should be one of the types listed in the rule above.
How I ended up solving it:
根据下面的答案提示,我最终将上传文件的MIME类型存储到一个$mime
变量中,如下所示:
$file = Input::file('file');
$mime = $file->getMimeType();
然后必须编写一条if语句来判断视频MIME类型:
if ($mime == "video/x-flv" || $mime == "video/mp4" || $mime == "application/x-mpegURL" || $mime == "video/MP2T" || $mime == "video/3gpp" || $mime == "video/quicktime" || $mime == "video/x-msvideo" || $mime == "video/x-ms-wmv")
{
// process upload
}