I have a javascript function as so:
function uploadFiles(PIRid) {
var fileInput = $('#incidentFiles');
var fileCount = fileInput[0].files.length;
for (i = 0; i < fileCount; i++){
var Obj = new Object();
Obj.Name = fileInput[0].files[i].name;
var reader = new FileReader();
Obj.File = reader.readAsBinaryString(fileInput[0].files[i]);
Obj.PIRid = PIRid;
Obj.RemoteID = RemoteID;
var data = JSON.stringify(Obj);
$.ajax({
type: "POST",
url: BaseHref + "/api/PIRfiles/",
data: data,
contentType: "application/json; charset=UTF-8",
success: function (response) {
$('#SaveSuccess').modal();
},
error: function (e) {
$('#SaveFailure').modal();
}
});
}
Im trying to find the correct call to import the file so it matches the C# API object as so:
public class ApiPIRfile
{
public string Name;
public byte[] File;
public string PIRid;
public string RemoteID;
}
The call goes through but the physical file is empty. What am I missing?