当我在summernote中更新文件图像时,我使用回叫更新图像。没关系。 但是我提交表单,文件在请求中再次发送,我想提交表单而不是再次发送文件。
$('.textarea-editor').summernote({
height: 300, // set editor height
minHeight: null, // set minimum height of editor
maxHeight: null, // set maximum height of editor
focus: true, // set focus to editable area after initializing summernote
callbacks: {
onImageUpload: function (files, editor, welEditable) {
sendFile(files[0], editor, welEditable);
}
}
});
function sendFile(file, editor, welEditable) {
data = new FormData();
data.append("file", file);
$.ajax({
data: data,
type: "POST",
url: "/Image/Upload",
cache: false,
contentType: false,
processData: false,
success: function (url) {
$('.textarea-editor').summernote('editor.insertImage', url);
//editor.insertImage(welEditable, url);
}
});
}
答案 0 :(得分:0)
请尝试以下解决方案:
// onImageUpload callback
$('.textarea-editor').summernote({
callbacks: {
onImageUpload: function(files) {
// upload image to server and create imgNode...
$summernote.summernote('insertNode', imgNode);
}
}
});
// summernote.image.upload
$('.textarea-editor').on('summernote.image.upload', function(we, files) {
data = new FormData();
data.append("file", files);
$.ajax({
data: data,
type: "POST",
url: "/Image/Upload",
cache: false,
contentType: false,
processData: false,
success: function (url) {
$summernote.summernote('insertNode', url);
}
});
});
答案 1 :(得分:0)
从您的表单标签中删除enctype =“ multipart / form-data”