lundi 24 juillet 2017

I am experiencing the following error in laravel when uploading image "The cat img must be a file of type: jpg, jpeg, png"

The cat img must be a file of type: jpg, jpeg, png.

here is my blade

<form  enctype="multipart/form-data" method="post">     @foreach ($errors->all() as $error)     <p class="alert alert-danger"></p> @endforeach  @if(session('status')) <div class="alert alert-success">  </div> @endif
              <div class="box-body">  <input type="hidden" name="_token" value="{!! csrf_token() !!}">

                <div class="form-group">
                 <label for="cat_name" class="col-lg-2 control-label"> <dt>Category Title</dt></label><div class="col-xs-5">
                        <input type="text" class="form-control" id="cat_name" placeholder="Category Title" name="cat_name">
                       </div>
                </div>
               <br>  <br>
                <div class="form-group">
                  <label for="cat_image" class="col-lg-2 control-label"><dt>Category Image</dt></label><div class="col-xs-5">
                 <input type="file" class="form-control" id="cat_img"  placeholder="Category Image" name="cat_img"><br>  <div id="imagePreview"></div>

                     </div>

                </div>

Here is my Controller

> public function messages()
>     {
>         return [
>         'cat_name.required'=>  'Input Category Title',
>         'cat_img.required'=>  'Input Image Format: jpg, jpeg, png',  ];
>     }
>      public function rules()
>     {
>         return [
>        'cat_name'=>  'required|min:2',
>        'cat_img'=>  'required |mimes:jpg,jpeg,png| max:5000', ];
>     } }

I am uploading the right type of image formats.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire