How to upload Excel file using Summernote?

帅比萌擦擦* 提交于 2019-12-12 14:03:17

问题


I am implementing CMS tool in my website and for that I'm using Summernote Editor. Now I want to upload Excel file using Summernote. How can I upload Excel file using Summernote?

Below is the code that creates a custom button for File upload. Clicking that button open a file browser from where I can select file, but I am not getting what to do next to show path or name("~/uploads/abc.xls" / abc.xls) of the selected file in editor to let user know that selection completed. Make it editable also i.e. if user want to change the file he can simply delete the file and select other one.

     var editor = $('#Contents');
        editor.summernote({
            focus: false,
            oninit: function () {

                var uploadExcelFileBtn = '<button id="uploadFile" type="button" class="btn btn-default btn-sm btn-small" title="Upload File"><i class="fa fa-upload"></i></button>';
                var fileGroupNew = '<div class="note-file btn-group">' + uploadExcelFileBtn + '</div>';

                $(fileGroupNew).appendTo($('.note-toolbar'));

                $('#uploadFile').tooltip({ container: 'body', placement: 'bottom' });

                $('#uploadFile').click(function (event) {
                    $("#file").click();

                    $(":file").change(function (evt) { 
                        var file = evt.target.files; //Here I get the file
                    });

                });
            },

        });

来源:https://stackoverflow.com/questions/34609245/how-to-upload-excel-file-using-summernote

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