Laravel 5 - 验证哑剧类型

2022-08-30 20:28:16

我有一个没有规则的上传器工作正常,但是当我创建规则时,我得到错误:

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() !!}

答案 1

您应该在 php 中启用以下行.ini然后重新启动 apache

extension=php_fileinfo.dll

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

即,从这个到;extension=php_fileinfo.dllextension=php_fileinfo.dll


答案 2

我有同样的问题,但没有问题。我更改了PHP版本,问题已修复extension=php_fileinfo.dll


推荐