zoukankan      html  css  js  c++  java
  • 调用KEditor批量上传图片

    调用KEditor批量上传图片:

    1. <script charset="utf-8" src="/Keditor/kindeditor.js"></script>
    2. <script charset="utf-8" src="/Keditor/lang/zh_CN.js"></script>
    3. <script charset="utf-8" src="/Keditor/editor.js"></script>
    4. <script>
    5.             KindEditor.ready(function(K) {
    6.                 var editor = K.editor({
    7.                 cssPath : 'Keditor/plugins/code/prettify.css',
    8.                 uploadJson : 'Keditor/asp/upload_json.asp',
    9.                 fileManagerJson : 'Keditor/asp/file_manager_json.asp',
    10.                 allowFileManager : true,
    11.                 });
    12.                 K('#J_selectImage').click(function() {
    13.                     editor.loadPlugin('multiimage', function() {
    14.                         editor.plugin.multiImageDialog({
    15.                             clickFn : function(urlList) {
    16.                             var div = K('#F_Main_Pic');
    17.                                 div.html('');
    18.                                 var str='';
    19.                                 K.each(urlList, function(i,data) {
    20.                                 str=str+data.url+"|";
    21.                                     });
    22.                                     K('#F_Main_Pic').val(str);
    23.                                 editor.hideDialog();
    24.                             }
    25.                         });
    26.                     });
    27.                 });
    28.             });
    29. </script>

    html页面内头部首先导入需要的JS文件。

    注意路径问题。我的KEditor目录和页面在一个目录下

    下面是一个按钮J_selectImage和一个文本框F_Main_Pic,按钮点击后会调用批量上传图片的组件,文本框负责接收图片的路径,以“|”分割。

    [html][/html] view plaincopy
     
    1. <input name="F_Main_Pic" type="text" id="F_Main_Pic" size="50">
    [html][/html] view plaincopy
     
    1. <input type="button" value="上传图片..." name="J_selectImage" id="J_selectImage" />

    接收到图片的路径,接下来你们知道怎么做了。想入库就入库,想显示就显示。不过先用split以“|”分割,才能得到每一个图片的路劲。

    http://www.devba.com/index.php/archives/2169.html

  • 相关阅读:
    Seaslog高性能日志系统学习
    同步、异步与阻塞、非阻塞、协程
    SQL常用增删改查语句
    js里的document对象大全(DOM操作)
    php的cURL资源的初步使用
    hive学习笔记(初级)
    使用NSIS制作可执行程序的安装包
    C#设置一个控件可以鼠标拖动
    C#画图超出屏幕的部分无法显示的解决方法
    C#获取当前不同网卡对应的iP
  • 原文地址:https://www.cnblogs.com/yuhoukongshan/p/6179104.html
Copyright © 2011-2022 走看看