I am struggling with submitting a form to upload a file using AJAX. My main issue is sending the temporary path to PHP and then receiving an array as a response.
Essentially, my goal is to submit the form, retrieve the temp path, pass it to PHP through JS, and finally have PHP return an array in response to JS
This is the current code I have developed:
<form name="form1" id="frmXML" method="post" action="">
<div>
<label for='upload'>Add XML:</label>
<input id='upload' name="upload[]" type="file" accept=".xml" multiple="multiple" onchange="doSelect(this)"/>
</div>
JS:
function doSelect(el){
$.ajax({
type : 'POST',
data: {
path:this.document.getElementById('upload').value,
submit: 'submit',
}
url : 'Logic/User.php',
dataType:'json',
success : function(response){
var len =response.length;
if(len>0)
{
//Do something
}
}
});
return false;
}