我正在创建一个上传img服务。我的问题是我似乎无法从我的端点获取数据。
我正在使用ng-file-upload
和multer
HTML
<div class="button" ngf-select ng-model="vm.uploadedImages" name="file" ngf-pattern="'image/*'" ngf-accept="'image/*'" ngf-max-size="20MB"
ngf-min-height="100" ngf-resize="{width: 100, height: 100}">Select</div>
<button class="btn btn-primary btn-raised btn-sm" ng-click="vm.test()">save</button>
CONTROLLER
vm.test = function () {
console.log(vm.uploadedImages); // img getting the data
Upload.upload({
url: 'api/getTest', //webAPI exposed to upload the file
data: { file: vm.uploadedImages } //pass file as data, should be user ng-model
});
};
路线
router.post('/getTest', function (req, res) {
console.log('req', req.body); // getting blank value
res.send(req.body);
});