var name = jQuery('[data-field="name"]').val();
var email = jQuery('[data-field="email"]').val();
var inumber = jQuery('[data-field="inumber"]').val();
var rnumber = jQuery('[data-field="rnumber"]').val();
var date = jQuery('[data-field="date"]').val();
var amount = jQuery('[data-field="amount"]').val();
var feedback = jQuery('[data-field="name"]').val();
var file_attach = new FormData(jQuery('input[name^="media"]'));
jQuery.each(jQuery('input[name^="media"]')[0].files, function(i, file) {
file_attach.append(i, file);
});
jQuery.ajax({
type: 'POST',
data: { func: "sendMail", name,email,inumber,rnumber,date,amount,feedback,file_attach},
url: 'billing-information-mailer.php',
cache: false,
contentType: false,
processData: false,
success: function(data){
console.log(data);
}
});
I'm trying to pass form info and attachment to a php file to send an email, initially I just went with $.post
however I need to set processData to false so I shifted to $.ajax
, currently my PHP file is sending an empty return. the only code in my php file is print_r($_POST);
EDIT:
<input type="file" name="media" data-field="billing" id="vdnupload" name="vdnupload" placeholder="Proof of Payment">