I'm building a form with JQuery and PHP and everything seem to work accept the file upload. Json doesn't seem to like the $_FILES. The form uploads fine when javascript is turned off. Is this a known issue? If it is, is there a work around? How do JQuery plugins manage to do this?
Thank you!
JQUERY:
$('#mcContactForm').submit(function(e){
e.preventDefault();
// validate form
mcValidateForm();
// serialize and submit form data
$('.mcloading').show();
var mcFormData = $(this).serialize();
mcSubmitForm(mcFormData);
// -----------------------------------------------
// AJAX FORM SUBMIT
// -----------------------------------------------
function mcSubmitForm(mcFormData){
$.ajax({
type: 'POST',
url: 'contact.php',
data: mcFormData,
dataType: 'json',
cache: false,
timeout: 7000,
success: function(data) {
if(data.error === true){
...
}
else if(data.error === false){
...
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
...
},
complete: function(XMLHttpRequest, status) {
...
}
});
}
});