view - html
<div class="col-sm-6">
<div class="form-group">
<label for="summary_summernote">简介/规则</label>
<div id="summary_summernote"></div>
</div>
</div>
-js
$('#summary_summernote').summernote({
lang: 'zh-CN', // default: 'en-US'
minHeight: 500,
callbacks: {
onImageUpload: function(files) { //the onImageUpload API
img = sendFile(files[0]);
}
}
});
function sendFile(file) {
data = new FormData();
data.append("file", file);
$.ajax({
data: data,
type: "POST",
url: "<{spUrl c=proxytc a=uploadicon}>?retype=text",
cache: false,
contentType: false,
processData: false,
success: function(url) {
if (url == "permission_error") {
layer.msg("你没有操作权限", {icon: 5, closeBtn: 1, shadeClose: true});
} else if (url == "error") {
layer.msg("上传失败", {icon: 5, closeBtn: 1, shadeClose: true});
} else {
$("#summary_summernote").summernote('insertImage', url, 'image name'); // the insertImage API
}
}
});
}