Skip to content

Instantly share code, notes, and snippets.

@ggwebdev
Created December 20, 2016 11:24
Show Gist options
  • Save ggwebdev/4918276097cbd4cdf1cdd9f299cccd7d to your computer and use it in GitHub Desktop.
Save ggwebdev/4918276097cbd4cdf1cdd9f299cccd7d to your computer and use it in GitHub Desktop.
$(function () {
$('#summernote').summernote({
focus: true,
height: 250,
callbacks: {
onImageUpload: function(files) {
sendFile(files[0]);
}
}
});
function sendFile(file, editor, welEditable) {
data = new FormData();
data.append("file", file);
$.ajax({
data: data,
type: 'POST',
url: "/sumernote/img-upload",
cache: false,
contentType: false,
processData: false,
success: function(data){
$('#summernote').summernote('editor.insertImage', data.url);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus+" "+errorThrown);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment