【发布时间】:2018-02-07 10:17:47
【问题描述】:
我有一个html文件上传表单,提交后我会将用户输入文件作为formData,我将从angularjs触发nodejs api。
在 nodejs - 我想接收 formData 并上传到一些外部存储中。该外部存储还需要作为 formData 的输入文件。
但我无法在 nodejs 中接收 formData 作为 formData。
请任何人提出解决方案。
$scope.add = function(file) {
var fd = new FormData();
fd.append('file', file);
$http.post('/uploadFile', fd, {headers: {'Content-Type': undefined}}).then(function(response) {
console.log(response);
}, function errorCallback(response) {
console.log(response);
});
}
NodeJS
app.post('/uploadFile', function (req,res) {
console.log(req.body); //Undefined
})
HTML
<form name="addForm" ng-submit="add(videoFile)">
<input class="file-upload__input" type="file" file-model="videoFile" required>
</form>
【问题讨论】:
-
能否请您也发布您的
html代码?
标签: javascript angularjs node.js google-cloud-storage