首页 > 有什么办法可以实现编辑富文本时插入图片的功能

有什么办法可以实现编辑富文本时插入图片的功能

使用的是editor(http://lab.lepture.com/editor)富文本编辑器,加上了这样一段,
点击图片,弹出框使用了bootstrap-dialog插件,结果如下图:

报错: Uncaught InvalidStateError: Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('file') does not support selection.

求教各位大神怎么解决,或者有什么替代方案!!谢谢!!

代码如下:

var editor = new Editor();
      editor.render();

      $('.icon-image').click(function(){ 
        BootstrapDialog.show({
          title: '插入图片',
          // message: $('<form enctype="multipart/form-data" action="/uploadimage" method="post">本地图片: <input type="file" name="image"/><br/><input type="submit" value="upload" /></form>'),
          message: $('<p>本地图片: </p><input id="image" type="file" class="file" data-preview-file-type="text">'),
          buttons: [
            {
              label: '取消',
              cssClass: 'btn-default',
              action: function(dialog) {
                dialog.close();
              }
            },
            {
              label: '确定',
              cssClass: 'btn-primary',
              action: function(dialogRef) {
                $.ajax({
                  type: 'POST',
                  url: '/uploadimage',
                  data: {'image': image},
                  success: function(msg){
                    alert(msg);
                    dialogRef.close();
                  }
                });
              },
            }
          ]
        });
      });

另外,使用注释掉的message是可以把图片传到后台的!

【热门文章】
【热门文章】