Laravel 验证 pdf mime
Laravel validation pdf mime
我已经尝试了以下 mime 类型来验证 PDF files.but none 其中没有通过验证。
$rules = [
....
"file" => "required|mimes:application/pdf, application/x-pdf,application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf|max:10000"
....
]
只需添加文件扩展名
$rules = [
"file" => "required|mimes:pdf|max:10000"
]
来自 laravel 文档:
Even though you only need to specify the extensions, this rule
actually validates against the MIME type of the file by reading the
file's contents and guessing its MIME type.
更新:
从 Laravel 5.2 开始,您可以根据完整的 MIME 类型验证文件上传,new validation 规则调用:mimetypes
.
$rules = [
"file" => "required|mimetypes:application/pdf|max:10000"
]
我已经尝试了以下 mime 类型来验证 PDF files.but none 其中没有通过验证。
$rules = [
....
"file" => "required|mimes:application/pdf, application/x-pdf,application/acrobat, applications/vnd.pdf, text/pdf, text/x-pdf|max:10000"
....
]
只需添加文件扩展名
$rules = [
"file" => "required|mimes:pdf|max:10000"
]
来自 laravel 文档:
Even though you only need to specify the extensions, this rule actually validates against the MIME type of the file by reading the file's contents and guessing its MIME type.
更新:
从 Laravel 5.2 开始,您可以根据完整的 MIME 类型验证文件上传,new validation 规则调用:mimetypes
.
$rules = [
"file" => "required|mimetypes:application/pdf|max:10000"
]