i'm trying to validate an image field in a Laravel form using AJAX but it allways seems to be empty. Even if i've already selected an file. How can i do it to check if the file input is empty or not with the ajax validation?
The form code:
{{ Form::open('files'=>'true') }}
...
{{ Form::file('image') }}
...
{{ Form::close() }}
The AJAX call:
var form_data = $("#form").serialize();
$.ajax({
dataType:"json",
method:'post',
url:'/ajax/validate?'+form_data,
success:function(data){...}
});
The controller side:
...
$rules['image'] = 'required';
...
$validator = Validator::make(Input::all(),$rules);
if($validator->fails()){
...
}else{
...
}