【问题标题】:Summernote Editor - Cannot view image after uploadSummernote 编辑器 - 上传后无法查看图像
【发布时间】:2019-02-11 06:49:06
【问题描述】:

从我的文件夹上传后,无法在 Summer Note 中查看上传的图片

<script>
    $('#summernote').summernote({
        height: ($(window).height() - 300),
        callbacks: {
            onImageUpload: function(image) {
                uploadImage(image[0]);
            }
        }
    });

    function uploadImage(image) {
        var data = new FormData();
        data.append("image", image);
        $.ajax({
            url: 'Your url to deal with your image',
            cache: false,
            contentType: false,
            processData: false,
            data: data,
            type: "post",
            success: function(url) {
                var image = $('<img>').attr('src', 'http://' + url);
                $('#summernote').summernote("insertNode", image[0]);
            },
            error: function(data) {
                console.log(data);
            }
        });
    }
</script>

这是我在索引页面中的脚本。请帮助我

【问题讨论】:

    标签: php ajax summernote


    【解决方案1】:
    url: 'Your url to deal with your image',
    

    在上面的行中,您必须编写处理文件上传并返回(回显)其 url 的 .php 文件的名称。

    例如:

    url: 'upload.php',
    

    那么你当然必须实际创建一个正确的upload.php。

    【讨论】:

      猜你喜欢
      • 2015-12-07
      • 2016-11-14
      • 2019-08-25
      • 2015-12-11
      • 2016-02-18
      • 2018-09-04
      • 1970-01-01
      • 2016-06-07
      • 2022-07-31
      相关资源
      最近更新 更多