When working with Angular in conjunction with MVC, I am facing an issue where the HttpPostedFileBase
is coming up as null when attempting to upload a file.
This is how the HTML looks:
<input type="file" data-ng-model="fileName" onchange="angular.element(this).scope().fileInputChanged(this)">
Angular code snippet:
scope.fileInputChanged = function (element) {
scope.$apply(function (scope) {
console.log('files:', element.files);
_.each(element.files, function (element, index, list) {
scope.files.push(element);
});
});
}
// More Angular functions for uploading documents...
MVC code snippet:
public void UploadDocuments(HttpPostedFileBase file)
{
}
The request headers and payload details are provided below. How can I resolve this issue and make the file upload functionality work correctly?