I have one form with some fields in AngularJs. I want to add one more field in form to upload a file, Currently I am sending data to backend as json payload, how can I upload a file that's my question, I have one idea that is by using query string... Anyone can please let me know how can I do this thing. My code to upload text fields -
let settings = {
"url": "https://someurl",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
},
"data": JSON.stringify(data)
};
$.ajax(settings).done(function (response) {
toastr["success"]("Form submitted succesfully.", "Success!");
setTimeout(function () {
window.location.href = "success.php";
}, 1500);
}).fail(function (err) {
toastr["error"]("Cannot submit your form.", "Failed!");
}
};
I am using AngularJs for the frontend.