locked
how can we get Image url instead of Base64 using Summernote editor in asp.net ? RRS feed

  • Question

  • User-1027654633 posted

    how can we get Image url instead of Base64 using Summernote editor in asp.net ?

    Thursday, February 7, 2019 5:58 AM

All replies

  • User-943250815 posted

    Sometimes, image URL is not a link to file, but a Base64 string that represents an image of specific type, you can name it as In-Line Image

    Thursday, February 7, 2019 11:54 PM
  • User-1174608757 posted

    Hi lokesh0443,

    According to your description,Summernote editor will  encodes image files into Base64. I guess you would like to save file in database, so the data is too heavy.

    So, I suggest to write custom function for onImageUpload( ) in scrip,then in aspx, you could save the Base64 data as url in the file .Here is  js code , I hope it could help you.

    <script>
        $(document).ready(function() {
            $('#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: "Your URL POST (php)",
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function(url) {
                        editor.insertImage(welEditable, url);
                    }
                });
            }
        });
    
    
    </script>

    Best Regards

    Wei Zhang

    Friday, February 8, 2019 3:50 AM