表单数据未附加文件对象
form data is not appending file object
我在将文件对象附加到表单数据时遇到问题,将文件对象附加到表单数据后,表单数据为空object.Please 建议
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);
//}
//);
}
};
FormData Object 是一个外来对象,其内容不能直接用于 JavaScript。
要检索 FormData 对象的内容,请使用其 .entries()
方法:
var contents = Array.from(formData.entries());
console.log(contents);
有关详细信息,请参阅 MDN Web API Reference - FormData.entries()
我在将文件对象附加到表单数据时遇到问题,将文件对象附加到表单数据后,表单数据为空object.Please 建议
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);
//}
//);
}
};
FormData Object 是一个外来对象,其内容不能直接用于 JavaScript。
要检索 FormData 对象的内容,请使用其 .entries()
方法:
var contents = Array.from(formData.entries());
console.log(contents);
有关详细信息,请参阅 MDN Web API Reference - FormData.entries()