I'm not sure how to do that -
I have form with text fields and number of files input (images) how do i submit the files with ajax? how the jquery script should look like?
<form id="attrac-form-<?PHP echo $mainIndex['id'] ?>" action="#" method="post" enctype="multipart/form-data" class="attrac-form">
<input type="file" name="file[]">
<input type="file" name="file[]">
<input type="file" name="file[]">
<input class="attrac-submit" value="SEND" type="submit" >
</form>
This is my current js for the text field
$(document).on("click", ".attrac-submit", function(e){
e.preventDefault();
var formData = $(this).closest('form').serializeArray();
formData.push({name: 'act', value: 'edit'});
submitAtractionForm (formData);
});
function submitAtractionForm(formData)
{
$.ajax ({
type: 'POST',
url: 'ajax/attractions.php',
data: formData,
dataType : 'json',
async: false,
code : true
}).done(function(data)
{
...
});
}