summernote基于Bootstrap的富文本编辑器,里面的上传图片处理。


话不多少,直接上干货。

  

function summernote() {
    $('.summernote').summernote({
        height: 200,
        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: "/upload/insert",
        cache: false,
        contentType: false,
        processData: false,
        success: function(url) {
            alert(url);
            editor.insertImage(welEditable, url);
        }
    });
}
summernote.js

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM