在向文件对象添加表单数据时出现问题,将文件对象附加到表单数据之后,表单数据为空对象。请建议
scope.uploadDigitalSignature = function (form) {
if (scope.digitalFiles.length) {
scope.docDetails.aliasName = scope.docDetails.aliasName;
scope.docDetails.digipassword = scope.docDetails.digipassword;
scope.docDetails.certificate = scope.docDetails.certificate;
var file = scope.digitalFiles[0];
var formData = new FormData(this);
formData.append('file', file);
// FileUpload.upload(scope.digitalFiles,docId,function(success,blobData){
var config = {
headers: {
'Content-Type': 'multipart/form-data',
}
};
var blobData = {
"file" : scope.docDetails.certificate
};
AdminService.uploadDigitalSignature(function(){
toastr.success('Signature uploaded successfully');
},docId,scope.docDetails.aliasName,scope.docDetails.digipassword ,blobData,config);
//}
//);
}
};
答案 0 :(得分:2)
FormData Object是一个奇异对象,其内容不可直接用于JavaScript。
要检索FormData对象的内容,请使用其.entries()
方法:
var contents = Array.from(formData.entries());
console.log(contents);