zoukankan      html  css  js  c++  java
  • UEditor编辑器上传图片开发流程

    在ueditor目录下找到uedior.config.js,找到如下三行:

    1 ,imageUrl: "<%=path %>/controller.json" //图片上传提交后台对应的地址,路径固定为*/controller.*
    2 ,imagePath: "<%=path %>/ueditor/" //图片在服务器上的存储目录
    3 ,imageFieldName: "upload" //后台对应接收image的参数名

    或者:

    var ueditor = UE.getEditor('myEditor',{
        imageUrl: "<%=path %>/servlet/UploadServlet", //图片上传提交后台对应的地址
        imagePath: "<%=path %>/ueditor/",  //图片在服务器上的存储目录
        imageFieldName: "upload"  //后台对应接收image的参数名
    });

    注意:记得在uedior.config.js配置文件中把"serverUrl"注释掉

    在/ueditor/_src/plugins/simpleupload.js文件中,把link = me.options.imageUrlPrefix + json.url; 改为link = getRootPath()+json.url;

    最后配置服务器返回的数据格式,这需要这服务器端进行修改。对应于后台接收上传图片的那个controller,返回的格式需如下:

    {'url':'60391393848223.jpg','title':'p1999637039.jpg','original':'p1999637039.jpg','state':'SUCCESS'}

    注意:url用相对路径,这样就OK了。

    复制代码
    //js获取项目根路径,如: http://localhost:8083/uimcardprj
    
    function getRootPath(){
    
        //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
    
        var curWwwPath=window.document.location.href;
    
        //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
    
        var pathName=window.document.location.pathname;
    
        var pos=curWwwPath.indexOf(pathName);
    
        //获取主机地址,如: http://localhost:8083
    
        var localhostPaht=curWwwPath.substring(0,pos);
    
        //获取带"/"的项目名,如:/uimcardprj
    
        var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    
        //return localhostPaht + projectName;
    
        return localhostPaht+"/";
    
    }
  • 相关阅读:
    MS SQL 挑战问题
    ORA00060错误
    用SYS本地登录或远程登录引起ORA01031错误
    RhelServer 5.5 安装ORACLE10
    sys不能远程登录的问题
    ORA12504:TNS:监听程序在CONNECT_DATA中未获得SERVICE_NAME
    MERGE INTO 性能问题疑问
    断开网线后监听服务器配置
    ORACLE——Instant Client配置SQL*LDR、EXP等命令工具
    监听服务管理
  • 原文地址:https://www.cnblogs.com/danson/p/4996699.html
Copyright © 2011-2022 走看看