Created
December 20, 2016 11:24
-
-
Save ggwebdev/4918276097cbd4cdf1cdd9f299cccd7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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