问题
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