在这里我正在使用角度文件上传,而我正在将数据发送到Api。我收到的数据为[{"file":{},"fname":"111"}]
,在这里我丢失了文件数据
这是我的AngularCode
$scope.UploadFile = function () {
var data = new FormData();
angular.forEach($scope.fileList, function (value, key) {
data.append(key, value);
});
data.append("DealModel", angular.toJson($scope.fileList));
AddDealService.AddDeal(data).then(function (response) {
alert("Added Successfully");
}
})
这是我的服务电话
app.factory('AddDealService', ['$http', function ($http) {
var fac = {};
fac.AddDeal = function (data) {
debugger;
return $http.post("http://localhost:58090/api/Home/GetData", data, {
withCredentials: true,
headers: { 'Content-Type': undefined },
transformRequest: angular.identity
})
}
return fac;
}])
我的Api
var model = HttpContext.Current.Request.Form["DealModel"];
此处将数据获取为
[\[{"file":{},"fname":"111"}\]][1]