Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 - Validating Mime types

Tags:

php

laravel-5

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?)

My article request rules

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    return [

        'Image' => 'required|mimes:jpeg'

    ];
}

My form

{!! 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() !!}
like image 360
BrunoMartinsPro Avatar asked May 22 '15 21:05

BrunoMartinsPro


1 Answers

You should enable the following line in your php.ini and then restart your apache

extension=php_fileinfo.dll

Enabling mean just uncomment the line in your php.ini file

i.e., From this ;extension=php_fileinfo.dll to extension=php_fileinfo.dll

like image 59
Sulthan Allaudeen Avatar answered Oct 20 '22 17:10

Sulthan Allaudeen