• ueditor上传路径改成绝对路径


     由于ueditor默认是上传到项目的根目录下,

    重新部署项目之前上传的文件会被清空,所以需要将文件保存到项目目录之外。

    方法如下:

    ① config.json新增配置:"saveRootPath": "d:/data/"

    /* 前后端通信相关的配置,注释只允许使用多行方式 */
    {
        "saveRootPath": "d:/data/", /* 文件和图片上传绝对根路径*/
        /* 上传图片配置项 */
        "imageActionName": "uploadimage", /* 执行上传图片的action名称 */
        "imageFieldName": "upfile", /* 提交的图片表单名称 */
        "imageMaxSize": 52428800, /* 上传大小限制,单位B,最大50MB */
        "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
        "imageCompressEnable": true, /* 是否压缩图片,默认是true */
        "imageCompressBorder": 1600, /* 图片压缩最长边限制 */
        "imageInsertAlign": "none", /* 插入的图片浮动方式 */
        "imageUrlPrefix": "/data", /* 图片访问路径前缀 */
        "imagePathFormat": "/ueditor/upload/image/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */

    ② 修改ueditor-1.1.2.jar 中的源码

    在ConfigManager.getConfig方法中新增配置:conf.put("saveRootPath", this.jsonConfig.getString("saveRootPath"));

    public Map<String, Object> getConfig(int type) {
            Map<String, Object> conf = new HashMap<String, Object>();
            String savePath = null;
            switch (type) {
            case 4:
                //省略
            case 1:
                //省略
            case 3:
                //省略
            case 2:
                //省略
            case 5:
                //省略
            case 7:
                //省略
            case 6:
                //省略
            }
            conf.put("savePath", savePath);
            conf.put("rootPath", this.rootPath);
            conf.put("saveRootPath", this.jsonConfig.getString("saveRootPath"));
            return conf;
        }

    将BinaryUploader.save方法中的 rootPath 修改为 saveRootPath

    //String physicalPath = String.valueOf(conf.get("rootPath")) + savePath;
    String physicalPath = String.valueOf(conf.get("saveRootPath")) + savePath;

    ----------------------经过以上修改,即可上传文件到自定义到绝对路径

    但是会出现无法预览的问题

    方案1,在tomcat的server.xml中新增虚拟映射地址:<Context docBase="D:/data" path="/data" reloadable="true"/>

    <?xml version="1.0" encoding="UTF-8"?>
    
          <!-- 省略 -->
      
          <Context docBase="ds-eop-war" path="/ds-plan-web" reloadable="true" source="org.eclipse.jst.jee.server:ds-eop-war"/>
          <Context docBase="D:/dssystem" path="/dssystem" reloadable="true"/>
          </Host>
        </Engine>
      </Service>
    </Server>

    然后重启tomcat。 无法预览的问题就此解决

    方案2  ?

  • 相关阅读:
    c#对XML读取
    WPF--TypeConverter使用
    WPF---对于没有Command属性的添加以下代码可以达到有Command效果
    自定义事件、属性、方法
    读取Excel文件
    ClickOnce安装部署,手动。
    Logger 日志记录
    Maven
    等待与通知范式
    线程状态及基本方法
  • 原文地址:https://www.cnblogs.com/Alwaysbecoding/p/12841434.html
Copyright © 2020-2023  润新知