AL-zami
AL-zami

Reputation: 9076

wrong mime type error

i am new to laravel.Here i am trying to create an image upload and validation functionality .I am using laravel 5.2.I have the following form in my create.blade.php file.

   {!!Form::open(array('url'=>'user')) !!}

   {!!Form::label('name','Your name')!!}
   {!!Form::text('name')!!}
   </br>
   {!!Form::label('image','Upload an image')!!}
   {!! Form::file('image') !!}
    </br>                      
    {!!Form::label('password','Type Password')!!}</br>
    {!!Form::password('password','',array('placeholder'=>'put your password here'))!!}
    </br>


    {!!Form::submit('submit')!!}
    {!!Form::close()!!}

in my userController.php resource controller ,inside store() function i have the following validation rule defined :

$rules = array(
   'name' => 'unique:users,name|required|alpha_num',
   'password'=>'required',
   'image' => 'mimes:jpeg,jpg,png,gif|required|max:10000'
);

no matter what image i upload i am getting the following error.How i can solve this problem?

enter image description here

Upvotes: 0

Views: 487

Answers (1)

Gagan
Gagan

Reputation: 5656

That is happening because the image is not being uploaded. You need to set the files => true whenever you are opening the form. For example see the following code

{!! Form::open(array('url'=>'user','method'=>'POST', 'files'=>true)) !!}

{!! Form::close()!!}

Upvotes: 1

Related Questions