0

I'm having issues with the jQuery Validation Plugin, the input file it's not recongnize by the method of the form. This is what I got: myform

The class validate of the form is what I use for initialize the plugin. And it works, it validates the input but when I click on "Guardar" and print_r('$_FILES'); what I get is array(). If I don't add the class validate to the form (Don't intialize the Plugin) then I get the data but without validation. What can I do?

1 Answer 1

3

Ajax requests cannot handle file input type, that is the reason you are not getting the file data in the server.

If you want to support only html5 FileAPI supported browsers then you can have a look at FormData to submit a file using ajax. You can read more about how to use FormData here and here

var form = document.getElementById('form-id');
var formData = new FormData(form);
$.ajax({
   url: '',
   data: formData
})

If you want to support cross browser then you need to look at a plugin like jQuery Form which simulates a ajax like form handling using iframes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.