I have a upload file control that uploads the file data to a MVC Controller . I also want to send additional upload details model object in the same request.
But for file - upload the request content-type undefined works for me. But for the MVC controller to effectively receive the model data it has to be application/json. How would I do that in a single request ?
Or, is there any other approach I can follow ? Please suggest. For the upload to complete I need both the data to be sent to the server.
I am doing is
var formdata;
$scope.getTheFiles = function ($files) {
formdata = new FormData();
angular.forEach($files, function (value, key) {
formdata.append(key, value);
});
and
$scope.validateFiles = function () {
var params = UploadDataServices.getGroupMembershipUploadParams();
$scope.pleaseWait = { "display": "block" };
var request = {
method: 'POST',
url: BasePath + 'uploadNative/ValidateFiles/',
data: formdata,
headers: {
'Content-Type': undefined
}
};
// SEND THE FILES.
console.log(formdata);
if (formdata != null || formdata != undefined) {
$http(request)
And in the MVC controller I get the File Data as
System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
Now I want to send that params also in the request which I got via
var params = UploadDataServices.getGroupMembershipUploadParams();
How would I do that ? I tried doing
var request = {
method: 'POST',
url: BasePath + 'uploadNative/ValidateFiles/',
data: {formdata:formdata,arg:params},
headers: {
'Content-Type': undefined
}
};
But I could not access the File Data .
Please suggest a way .
Thanks in advance.