У меня проблема с редактором 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/