ueditor单独图片和附件上传功能

首要要载入ueditor的2个js

    <script src="../ueditor/ueditor.config.js" type="text/javascript"></script>
    <script src="../ueditor/ueditor.all.js" type="text/javascript"></script>

  

    <table>
      <tr>
        <td>
            <asp:TextBox ID="txtImgurl" runat="server"></asp:TextBox>
            <input type="button" id="btnImageUpLoader" value="上传" οnclick="upImage()" />
          </td>
      </tr>
      <tr>
        <td>
            <asp:TextBox ID="txtAttachments" runat="server"></asp:TextBox>
            <input type="button" id="btnFileUpLoader" value="上传" οnclick="upFile()" />
          </td>
      </tr>
     </table>

  

<script type="text/javascript">
    UE.getEditor('txtContent');
</script>
    
   <script type="text/javascript">
       var myEditor = new UE.ui.Editor;
       myEditor.render('btnFileUpLoader'); 
       myEditor.ready(function() {
           myEditor.setDisabled();
           myEditor.hide();
           myEditor.addListener('beforeInsertImage', function (t, arg) {      
                //因为可以上传多张,所以就用arg[0]
               $("#txtImgurl").attr("value", arg[0].src);
           });
           myEditor.addListener('afterUpfile', function (t, arg) {                    //这里这个事件需要到 dialogs\attachment\attachment.html 中                                                                               //在editor.execCommand("insertHTML",str);前面添加
               $("#txtAttachments").attr("value", arg[0].url);                        //editor.fireEvent('afterUpfile', filesList);
           });
       });
       function upImage() {
           var m;
           m = myEditor.getDialog("insertimage");
           m.render();
           m.open();
       }
       function upFile() {
           var f;
           f = myEditor.getDialog("attachment");
           f.render();
           f.open();
       }
       //在使用ueditor单独附件上传功能的时候点击"上传"按钮时不会出现 文件上传对话框,
       //Uncaught TypeError: Cannot read property 'render' of undefined 这是因为在ueditor.config.js 
       //中对toolbars 配置是把 'attachment' 工具去掉了,只要添加上去就可以了

   </script>

 

转载于:https://www.cnblogs.com/xinianxinqix/p/4220752.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值