I'm trying to upload files from a form asynchronously, but I have a problem
I add the form files this way
function composeFormData(oldFormData,form){
oldFormData.push({name:"doc_files",value:doc_filestore});
oldFormData.push({name:"desc_files",value:filestore});
$.ajax({
url: "save.php",
data: oldFormData,
type: "POST",
dataType:"html",
enctype: 'multipart/form-data',
//processData: false
}).done(function(response) {
console.log(response);
});
}
without processData:
false ,the value of doc_files,and desc_files are a string instead of a file and with processData: false
, $_POST is empty.
But before send the request formdata['desc_files']
and formdata['doc_files']
are files arrays.
What am I doing wrong?