Browse Source

上传文件windows去除盘符

RuoYi 5 years ago
parent
commit
2b20edeff8

+ 1 - 1
ruoyi-admin/src/main/resources/templates/system/user/add.html

@@ -53,7 +53,7 @@
                     <div class="form-group">
                         <label class="col-sm-4 control-label"><span style="color: red; ">*</span>登录账号:</label>
                         <div class="col-sm-8">
-                            <input name="loginName" placeholder="请输入登录账号" class="form-control required" type="text" maxlength="30" required>
+                            <input name="loginName" placeholder="请输入登录账号" class="form-control" type="text" maxlength="30" required>
                         </div>
                     </div>
                 </div>

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

@@ -113,7 +113,12 @@ public class FileUploadUtils
 
         File desc = getAbsoluteFile(baseDir, fileName);
         file.transferTo(desc);
-        String pathFileName = StringUtils.substringAfterLast(baseDir, ":") + fileName;
+        String pathFileName = baseDir + fileName;
+        if (StringUtils.contains(baseDir, ":"))
+        {
+            // windows 去除盘符
+            pathFileName = StringUtils.substringAfterLast(baseDir, ":") + fileName;
+        }
         return pathFileName;
     }