我有一个基本的 AngularJS 代码来将文件发送到我的 REST Controller 。 当我上传大约 500 KB 的文本文件时,它工作正常。当大小超过 600 KB 时,我收到“500 内部服务器错误”,并且请求未到达后端应用程序的 REST Controller
我听说更改 header 可以解决此问题。有人可以帮忙吗?
HTML:
<input type="file" name="file" onchange="uploadFile(this.files)"/>
AngularJS:
$scope.uploadFile = function(files) {
var fd = new FormData();
//Take the first selected file
fd.append("file", files[0]);
var uploadUrl = ApiUrlFull + 'Job/Item?smartTermId=0&name=aaa1&quantity=1&ApiKey=ABC';
$http.post(uploadUrl, fd, {
withCredentials: true,
headers: {'Content-Type': undefined },
transformRequest: angular.identity
}).success( ...all right!... ).error( ..damn!... );
};
最佳答案
问题出在后端 REST 应用程序
CommonsMultipartResolver 的最大大小设置为 0.5 MB 将大小增加到所需的大小。
关于javascript - 当文件超过 500KB 时,AngularJS 文件上传显示 500 内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46429568/