Commit 93f14a3020e6230232208a8210c30f6c86440586

Authored by 周峰
1 parent 12008f99

修复头像上传功能

src/main/java/com/huaheng/common/utils/file/FileUploadUtils.java
... ... @@ -130,7 +130,7 @@ public class FileUploadUtils
130 130 }
131 131 if (!desc.exists())
132 132 {
133   - desc.createNewFile();
  133 +// desc.createNewFile();
134 134 }
135 135 return desc;
136 136 }
... ...
src/main/java/com/huaheng/pc/system/user/controller/ProfileController.java
... ... @@ -138,6 +138,7 @@ public class ProfileController extends BaseController
138 138 if (!file.isEmpty())
139 139 {
140 140 String avatar = FileUploadUtils.upload(file);
  141 + user.setId(getUser().getId());
141 142 user.setAvatar(avatar);
142 143 if (userService.updateUserInfo(user) > 0)
143 144 {
... ...
src/main/resources/application.yml
... ... @@ -11,7 +11,7 @@ huaheng:
11 11 #版权年份
12 12 copyrightYear: 2018
13 13 # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
14   - profile: D:/Huaheng/uploadPath
  14 + profile: D:/Huaheng/uploadPath/
15 15 # 获取ip地址开关
16 16 addressEnabled: false
17 17  
... ...
src/main/resources/templates/system/user/profile/avatar.html
... ... @@ -24,12 +24,12 @@
24 24 </div>
25 25 <div th:include="include::footer"></div>
26 26 <script th:src="@{/ajax/libs/cropbox/cropbox.js}"></script>
27   -<script type="text/javascript">
  27 + <script th:inline="javascript">
28 28 $(window).load(function() {
29 29 var options = {
30 30 thumbBox: '.thumbBox',
31 31 spinner: '.spinner',
32   - imgSrc: '/wms/img/profile.jpg'
  32 + imgSrc: '/wms/profile/' + [[${user.avatar}]]
33 33 }
34 34 var cropper = $('.imageBox').cropbox(options);
35 35 $('#avatar').on('change',
... ...
src/main/resources/templates/system/user/profile/profile.html
... ... @@ -35,7 +35,7 @@
35 35 <div class="contact-box">
36 36 <div class="col-sm-4">
37 37 <div class="text-center">
38   - <img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '../../img/profiles.jpg' : '/profile/' + ${user.avatar}">
  38 + <img alt="image" class="img-circle m-t-xs img-responsive" th:src="(${user.avatar} == '') ? '../../img/profiles.jpg' : '../../profile/' + ${user.avatar}">
39 39 <div class="m-t-xs font-bold">[[${user.loginIp}]]</div>
40 40 </div>
41 41 </div>
... ...