Browse Source

上传图片

wangtianteng 1 year ago
parent
commit
04c3431471

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/platform/UploadController.java

@@ -28,7 +28,7 @@ public class UploadController {
         UploadInfo uploadInfo = new UploadInfo();
 
         uploadInfo.setFileName(fileName);
-        uploadInfo.setUrl(filePath+fileNewName);
+        uploadInfo.setUrl(fileNewName);
 
         //返回文件名 和存放路径
         return R.ok(uploadInfo);

+ 5 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -145,6 +145,11 @@ public class Constants
     public static final String RESOURCE_PREFIX = "/profile";
 
     /**
+     * 资源映射路径 前缀
+     */
+    public static final String UPLOADPATH = "/uploadPath";
+
+    /**
      * RMI 远程方法调用
      */
     public static final String LOOKUP_RMI = "rmi:";

+ 1 - 1
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java

@@ -144,7 +144,7 @@ public class FileUploadUtils
     {
         int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
         String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
-        return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
+        return Constants.UPLOADPATH + "/" + currentDir + "/" + fileName;
     }
 
     /**