I have created a new step after payment on checkout onepage and form in this step contains a file type element. I have to upload a file and save file using Ajax. I'm using the formData
object in my js file to get the file details in $_FILES
array in php but it's not working. Doing simply like this in my js file.
save: function () {
//verifyStep = document.getElementById('verify-step').value;
var formElement = document.getElementById("co-verify-form");
var formData = new FormData(formElement);
console.log(formElement);
if (checkout.loadWaiting != false)
return;
if (this.validate()) {
checkout.setLoadWaiting('verify');
var request = new Ajax.Request(
this.saveUrl,
{
method: 'post',
onComplete: this.onComplete,
onSuccess: this.onSave,
onFailure: checkout.ajaxFailure.bind(checkout),
parameters: formData,
}
);
}
},