Angularjs ng-file-upload没有获取我的api端点上的数据

时间:2018-01-17 04:58:02

标签: javascript angularjs ng-file-upload

我正在创建一个上传img服务。我的问题是我似乎无法从我的端点获取数据。

我正在使用ng-file-uploadmulter

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);
});

0 个答案:

没有答案