2
我在AngularJS新,我试图上传与图像NG文件上传意外场NG-文件上传
我的任务是翻译的离子应用的web应用程序,所以我有重复使用相同的路线。
<button ngf-select="upload($file)" ng-model="file">Select</button>
$scope.upload = function (file) {
$scope.event.headerPictures.push(file);
console.log($scope.event);
console.log(file);
if (file && !file.$error) {
Upload.upload({
url: $config.baseUrl + '/api/event/upload-picture',
method: "POST",
headers: {"Authorization" : "token=" + userService.getToken()},
file: file,
}).then(function (resp) {
console.log('Success ' + resp.config.data.file.name + 'uploaded. Response: ' + resp.data);
}, function (resp) {
console.log('Error status: ' + resp.status);
}, function (evt) {
var progressPercentage = parseInt(100.0 * evt.loaded/evt.total);
console.log('progress: ' + progressPercentage + '% ' + evt.config.data.file.name);
});
};
};
我仍然得到同样的错误与许多不同的syntaxe:
Error: Unexpected field
谁能告诉我我失去了什么?
你得到什么错误? – danial
错误来自哪里?哪条线?是否在选择等之前上传? – danial
嗨Danial,错误来自POST完成。一旦文件被发送,我就可以在服务器控制台中获得它。 – Thounder