Summernote - Image url instead of Base64

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 02:22:56
Raghavendra N

You need to write custom function for onImageUpload().

I was looking for a solution. Found this: Summernote image upload

I had this problem with some of my applications as well. I created a detailed tutorial here https://a1websitepro.com/store-image-uploads-on-server-with-summernote-not-base-64/

You have to let summernote know that you are going to process the image file with a function.

    $(document).ready(function() {
    $("#summernote").summernote({
      placeholder: 'enter directions here...',
            height: 300,
            callbacks: {
            onImageUpload : function(files, editor, welEditable) {

         for(var i = files.length - 1; i >= 0; i--) {
                 sendFile(files[i], this);
        }
    }
}
});
});

Then create another function like this for the callback.

    function sendFile(file, el) {
    var form_data = new FormData();
    form_data.append('file', file);
    $.ajax({
        data: form_data,
        type: "POST",
        url: 'editor-upload.php',
        cache: false,
        contentType: false,
        processData: false,
    success: function(url) {
    $(el).summernote('editor.insertImage', url);
   }
    });
    }

Then you will need to create a php file. To handle the request. Notice the php file for this script is named editor-upload.php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!