AngularJS:Content Type标头始终设置为application / json而不是multipart / form-data

时间:2017-04-19 03:16:06

标签: angularjs asp.net-web-api multipartform-data

我尝试使用multipart / form-data实现简单的文件上传。

但请求标头内容类型设置为application / json。

以下是我的代码:

uploadFiles: function (files, successFunction, failFunction) {
    var formData = new FormData();

    angular.forEach(files, function (file, index) {
       formData.append('file', file.file);
    });

    $http.post(getServiceAddress() + '/api/upload', formData, {
       transformRequest: angular.identity,
       headers: {
          'Content-Type': undefined
       }
    }).success(successFunction).error(failFunction);
}

请求标题&请求有效载荷:

enter image description here

enter image description here

请注意,Content-Type标头仍在application / json中。

感谢任何帮助。

谢谢!

0 个答案:

没有答案