php – Laravel 5 – 验证Mime类型

前端之家收集整理的这篇文章主要介绍了php – Laravel 5 – 验证Mime类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个上传者没有规则的工作正常,
但是当我创建一个规则我得到错误
  1. LogicException in MimeTypeGuesser.PHP line 127:
  2. Unable to guess the mime type as no guessers are available
  3. (Did you enable the PHP_fileinfo extension?)

我的文章请求规则

  1. /**
  2. * Get the validation rules that apply to the request.
  3. *
  4. * @return array
  5. */
  6. public function rules()
  7. {
  8. return [
  9.  
  10. 'Image' => 'required|mimes:jpeg'
  11.  
  12. ];
  13. }

我的形式

  1. {!! Form::open(['url' => 'blog','files'=> true]) !!}
  2. <div class="form-group">
  3. {!! Form::label('Image','Upload:') !!}
  4. {!! Form::file('Image',null,['class' => 'form-control']) !!}
  5. </div>
  6. <div class="form-group">
  7. {!! Form::submit('Submit',['class' => 'btn btn-primary form-control']) !!}
  8. </div>
  9. {!! Form::close() !!}
您应该在PHP.ini中启用以下行,然后重新启动您的apache
  1. extension=PHP_fileinfo.dll

启用意味着只需取消注释PHP.ini文件中的行

即From this; extension = PHP_fileinfo.dll到extension = PHP_fileinfo.dll

猜你在找的Laravel相关文章