vendredi 4 septembre 2015

Submit form with file input return validation error in Laravel 5.1.*

I have this form

<form class="" enctype="multipart/form-data" action="{{route('submit_prop')}}" method="POST">
<div class="margin-btm-sm">
    <label>Main Image</label>
    <input type="file" name="main_img" class="form-control" />
</div>

  <div class="margin-btm-sm">
    <button type="submit" class="btn btn-primary">Save</button>
</div>
</form>

when submit the form the request array (POST array) is empty. but when remove enctype="multipart/form-data" from form

<form class="" action="{{route('submit_prop')}}" method="POST">

the request array has data.

Controller Method:

function submit($id=null) {
              dd(Input::all());

}

Request Contoller:

 public function rules()
{  

    return [
        'main_img' => 'image|mimes:png,jpg,jpeg',
    ];
}

what is the issue? i know the enctype is a must when submit a file. I used it in Laravel 5.0 and everything was ok why ij Laravel 5.1 did not work.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1hGhONB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire