I currently upload a file to my controller and it works fine:
On the client side:
var input = document.getElementById(inputId);
var formData = new FormData();
for (var i = 0; i != input.files.length; i++) {
formData.append("files", files[i]);
}
$.ajax({
url: "/api/ocr",
data: formData,
processData: false,
contentType: false,
type: "POST",
success: function(data) {...}
});
On the server side in the controller:
[HttpPost]
public async Task<IActionResult> Post(IList<IFormFile> files) {
IFormFile file = files[0];
// process file
}
Now I want to send another parameter to server: connectionId. So on the client side I added:
formData.append("connectionId", "123456");
and on the serverside, I amended the parameter to the Post method:
[HttpPost]
public async Task<IActionResult> Post(IList<IFormFile> files, string connectionId) {
...
}
However, connectionId parameter is always null. What am I missing?