我不理解url:'/ api / fileupload /', $ scope.uploadFiles = function(){
var request = {
method: 'POST',
url: '/api/fileupload/',
data: formdata,
headers: {
'Content-Type': undefined
}
};
// SEND THE FILES.
$http(request)
.success(function (d) {
alert(d);
})
.error(function () {
});
}
答案 0 :(得分:0)
这是我前一段时间使用angular:
上传xlm文件的代码this.uploadFile = function($file) {
// $http() returns a $promise that we can add handlers with .then()
return $http({
method: 'POST',
url: restUrl + "/rest/data/upload",
data: $file,
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
还要确保您接受服务器上的MediaType.MULTIPART_FORM_DATA