upload(item) {
let data= new FormData();
data.append('file', item.file);
data.append("editId", this.userInfo.userId);
data.append("orgId", this.userInfo.organ.orgId);
data.append("editor", this.userInfo.userName);
// const data = {
// file: file,
// editId: this.userInfo.userId,
// orgId: this.userInfo.organ.orgId,
// editor: this.userInfo.userName
// }
const params = {
orgId: this.userInfo.organ.orgId,
data: data,
};
//调用上传接口
uploadImage(formData)
.then(res => {
});
})
.catch(err => {
this.$message.error('上传失败,请重新上传');
});
},
--------------------------------------------------------------
更具体使用详见formData文件上传

此篇博客介绍了如何使用FormData对象进行文件上传,并强调了在上传过程中附带编辑者信息和组织ID的重要性。通过实例展示了如何构造FormData并调用上传接口处理上传失败情况。

被折叠的 条评论
为什么被折叠?



