【发布时间】:2020-12-15 11:37:16
【问题描述】:
我正在尝试为输入类型文件(图像)集成自定义编辑器。
editor: fileEditor,
还有一个函数叫做fileEditor
var fileEditor = function (cell, onRendered, success, cancel, editorParams) {
var cellId = cell.getRow().getData()._id;
var uploadTo = document.createElement("input");
uploadTo.setAttribute("type", "hidden");
uploadTo.setAttribute("name", "uploadTo");
uploadTo.setAttribute("id", "uploadTo");
uploadTo.setAttribute("value", "images/category");
var editor = document.createElement("input");
editor.setAttribute("type", "file");
editor.setAttribute("name", "imgFile");
editor.setAttribute("id", cellId+"_imgFile");
editor.style.padding = "3px";
editor.style.width = "100%";
editor.style.boxSizing = "border-box";
onRendered(function () {
editor.focus();
editor.style.css = "100%";
});
function successFunc() {
console.log(cell, editor.value)
if(editor.value != ""){
// cell.setValue(editor.value, true)
success(editor.value);
updateCategoryImage(cell, cell.getColumn().getField(), cell.getRow().getData()._id)
}else{
cell.cancelEdit();
}
}
editor.addEventListener("change", successFunc);
return editor;
};
在 updateCategoryImage() 中,我尝试使用 formdata 将此图像上传到 s3,但文件元素在 DOM 中不存在。请帮我解决这个问题。
谢谢。
【问题讨论】:
标签: javascript node.js tabulator