form data is not appending file object

こ雲淡風輕ζ 提交于 2019-12-24 10:26:13

问题


I have a problem in appending file object with form data,after appending file object to form data,form data is empty object.Please suggest

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);
//}

//);
}
};


回答1:


A FormData Object is an exotic object whose contents is not directly available to JavaScript.

To retrieve the contents of a FormData object, use its .entries() method:

var contents = Array.from(formData.entries());
console.log(contents);

For more information, see MDN Web API Reference - FormData.entries()



来源:https://stackoverflow.com/questions/55300330/form-data-is-not-appending-file-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!