とform-data
一緒に送っていimage-data
ます。
しかし、内部に送信すると、ノードサーバーでデータを取得できませんFormData
。
のangular
コントローラーでデータを見ることができましたconsole.log
。
角度コード:
$scope.saveInfo = function(){
var formData = new FormData;
console.log('Update function');
for(key in $scope.seller){
formData.append(key, $scope.seller[key]);
}
console.log(key, $scope.seller);
var file = $('#file')[0].files[0];
formData.append('image', file);
$http.put('/api/seller/businessInformation', formData, {
transformRequest: angular.Identity,
headers: {
'Content-type': undefined
}
}).then(function(res){
});
}
Node.jsの:私は、画像上のデータを見ることができたconsole.log(req.files);
、
しかしconsole.log(req.body);
印刷物[オブジェクトのオブジェクト]を。
問題は、ng-modelデータバインディングにあります。
私は次のようにデータをバインドしていました: 'seller.abc'
代わりにseller.a
、それは機能しました。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加