我有一个关于Summernote编辑器的问题。我希望上传图片到服务器上的目录中。 我有一些脚本:
<script type="text/javascript">
$(function () {
$(\'.summernote\').summernote({
height: 200
});
$(\'.summernote\').summernote({
height:300,
onImageUpload: function(files, editor, welEditable) {
sendFile(files[0],editor,welEditable);
}
});
});
</script>
<script type="text/javascript">
function sendFile(file, editor, welEditable) {
data = new FormData();
data.append("file", file);
url = "http://localhost/spichlerz/uploads";
$.ajax({
data: data,
type: "POST",
url: url,
cache: false,
contentType: false,
processData: false,
success: function (url) {
editor.insertImage(welEditable, url);
}
});
}
</script>
<td><textarea class="summernote" rows="10" cols="100" name="tekst"></textarea></td>
当然,我有所有js和CSS文件。我做错了什么?如果我单击图像上传并进入编辑器,图像不会显示在文本区域中。
如果我删除sendFile函数和onImageUpload,则图像将以base64格式保存。
Summernote链接:http://hackerwins.github.io/summernote/