小编mar*_*007的帖子

Summernote图片上传

编辑器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>
Run Code Online (Sandbox Code Playgroud)

当然我有所有的js和css文件.我做错了什么?如果我单击图像上传并转到编辑器,则图像不在textarea中.

如果我删除sendFile函数和onImageUpload:图像保存在base64上.

链接到summernote:http://hackerwins.github.io/summernote/

javascript upload image summernote

40
推荐指数
4
解决办法
9万
查看次数

标签 统计

image ×1

javascript ×1

summernote ×1

upload ×1