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