无法使用ng2-file-upload将带有表单数据的文件从angular上传到sails.js

时间:2018-06-04 11:34:56

标签: angular sails.js ng2-file-upload

我的app.component.html包含

<input type="file" ng2FileSelect [uploader]="uploader" #photoupload="ngModel" required id="photoupload" name="photo_upload" [(ngModel)]="personal.photo">

app.component.ts包含

this.uploader = new FileUploader({ url: "http://localhost:1337/api/fmng/create" });
this.uploader.onBeforeUploadItem = (item) => {
    var formData = [{ "formdata" : this.personal }];
    item.formData.push({ fileData: formData });

};

我的sails app控制器中的代码是

req.file('photo_upload').upload({ dirname: require('path').resolve(sails.config.appPath, 'assets/images') }, function (err, uploadedFiles) {
     if (err) return res.serverError(err);
     console.log('req all params ' + req.allParams());
}

为什么我的角度应用程序没有对URL进行请求?

0 个答案:

没有答案