Multer是与节点js一起使用的模块,并表示上传文件.我正在使用ng文件上传模块在角度.
当我一个接一个发送多个文件时,它工作正常,没有任何错误,但是当我以数组格式发送所有文件,然后我正在服务器端进行必要的更改,如Multer的github所建议的,仍然出现错误.
这是错误
Error: Unexpected field at makeError (C:\nodefiles\new\node_modules\multer\lib\make-error.js:12:13) at wrappedFileFilter (C:\nodefiles\new\node_modules\multer\index.js:39:19) at Busboy.<anonymous> (C:\nodefiles\new\node_modules\multer\lib\make-middleware.js:109:7) at Busboy.emit (events.js:118:17) at Busboy.emit (C:\nodefiles\new\node_modules\multer\node_modules\busboy\lib\main.js:31:35) at PartStream.<anonymous> (C:\nodefiles\new\node_modules\multer\node_modules\busboy\lib\types\multipart.js:209:13) at PartStream.emit (events.js:107:17) at HeaderParser.<anonymous> (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\Dicer.js:51:16) at HeaderParser.emit (events.js:107:17) at HeaderParser._finish (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\HeaderParser.js:70:8) at SBMH.<anonymous> (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\HeaderParser.js:42:12) at SBMH.emit (events.js:118:17) at SBMH._sbmh_Feed (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\node_modules\streamsearch\lib\sbmh.js:159:14) at SBMH.push (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\node_modules\streamsearch\lib\sbmh.js:56:14) at HeaderParser.push (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\HeaderParser.js:48:19) at Dicer._oninfo (C:\nodefiles\new\node_modules\multer\node_modules\busboy\node_modules\dicer\lib\Dicer.js:198:25)
样品控制器代码
var app = angular.module('fileUpload',['ngFileUpload']); app.controller('MyCtrl',['$scope','Upload','$timeout',function ($scope,Upload,$timeout) { $scope.uploadFiles = function (files) { $scope.files = files; if (files && files.length) { console.log(files); Upload.upload({ url: '/api/data/addtweet',data: { files: files } }).then(function (response) { $timeout(function () { $scope.result = response.data; }); },function (response) { if (response.status > 0) { $scope.errorMsg = response.status + ': ' + response.data; } },function (evt) { $scope.progress = Math.min(100,parseInt(100.0 * evt.loaded / evt.total)); }); } }; }]);
请告诉我我做错了什么
Google搜索不是很有用,我已经尝试过,即我在这里发布.