angular - 无法使用 ng2-file-upload 将带有表单数据的文件从 angular 上传到sails.js
问题描述
我的 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 });
};
我的风帆应用程序控制器中的代码是
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());
}
为什么我的 Angular 应用程序没有对 URL 发出请求?
解决方案
推荐阅读
- javascript - 变量不区分大小写的正则表达式匹配javascript
- amazon-s3 - 拼花地板 Pyspark 中的 UPSERT
- javascript - 如何使用来自用户输入的数据将对象添加到数组中?
- html - 当一个字体标签指定一个被渲染的面不知道渲染器应该使用什么其他字体时?
- gpu - 金属质感的右边缘有异常
- c# - 当我将字符串作为参数传递给另一个方法时,字符串的内容会丢失吗?
- bash - 如何使用 bash 脚本通过提示更改文件权限
- arduino - BLE 扫描仅在第一次扫描时获取某些设备的名称
- node.js - 如何在 Vue.js 中使用 BigQuery API
- c# - 无法通过 c# 连接到 Neo4j db