Laravel 5 - 验证 Mime 类型 [英] Laravel 5 - Validating Mime types
本文介绍了Laravel 5 - 验证 Mime 类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个上传器,可以正常运行,没有规则,但是当我创建规则时,我得到了错误:
I have an uploader that works fine without rules, but when i create a rule i get the error:
LogicException in MimeTypeGuesser.php line 127:
Unable to guess the mime type as no guessers are available
(Did you enable the php_fileinfo extension?)
我的文章请求规则
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'Image' => 'required|mimes:jpeg'
];
}
我的表格
{!! Form::open(['url' => 'blog', 'files'=> true]) !!}
<div class="form-group">
{!! Form::label('Image', 'Upload:') !!}
{!! Form::file('Image', null, ['class' => 'form-control']) !!}
</div>
<div class="form-group">
{!! Form::submit('Submit', ['class' => 'btn btn-primary form-control']) !!}
</div>
{!! Form::close() !!}
推荐答案
您应在php.ini中启用以下行,然后重新启动apache
You should enable the following line in your php.ini and then restart your apache
extension=php_fileinfo.dll
启用意味着只取消注释php.ini文件中的行
Enabling mean just uncomment the line in your php.ini file
即,从此; extension = php_fileinfo.dll
到 extension = php_fileinfo.dll
这篇关于Laravel 5 - 验证 Mime 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文