i am trying to upload a file using the following code in angular:
<input class="fromFileInput" id="VeryfyFromFileInput" type="file" fileread="fileContent" ng-click=uploadFile />
in my controller, I have the following code:
$scope.fileInformation = [];
$scope.uploadFile = function () {
$scope.fileModel = $('#VeryfyFromFileInput');
recordsService.passFile($scope.fileModel.context);
};
and in my service, I have the following code:
this.passFile = function (data) {
return $http({
method: 'POST',
url: url + "/GetFile",
data: data,
headers: { 'Content-Type': 'application/json' }
});
};
I am trying to pass the file to an ASP.NET MVC controller using the following code:
[HttpPost]
public void GetFile([FromBody] HttpRequestMessage file)
{
}
However, I always end up with a null value. Can anyone advise me on what type of parameter I should use instead of 'HttpRequestMessage '? Or could the issue be on the javascript side?