$(document).ready(function () {
$("#btnSubmit").click(function (event) {
//stop submit the form, we will post it manually.
event.preventDefault();
// Get form
var form = $('#fileUploadForm')[0];
// Create an FormData object
var data = new FormData(form);
// If you want to add an extra field for the FormData
data.append("CustomField", "This is some extra data, testing");
$.ajax({
type: "POST",
enctype: 'multipart/form-data',
url: "/api/upload/multi",
data: data,
processData: false, //Important, it prevent jQuery form transforming the data into a query string
contentType: false,
cache: false,
success: function (data) {
console.log("SUCCESS : ", data);//your logic
},
error: function (e) {
console.log("ERROR : ", e); //your logic
}
});
});
});