上传文件修改为返回完整路径

master
RuoYi 5 years ago committed by Limy
parent 79bdb50b90
commit a6f820c341

@ -27,11 +27,6 @@ public class CommonController
{
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
/**
*
*/
public static final String UPLOAD_PATH = "/profile/upload/";
@Autowired
private ServerConfig serverConfig;
@ -82,7 +77,7 @@ public class CommonController
String filePath = Global.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + UPLOAD_PATH + fileName;
String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success();
ajax.put("fileName", fileName);
ajax.put("url", url);

@ -40,7 +40,7 @@
{
title: '图片',
formatter: function(value, row, index) {
// 图片自由组合(注意:如存储在本地需要带上 '/profile/upload' + 数据库路径)
// 图片预览注意如存储在本地直接获取数据库路径如有配置context-path需要使用ctx+路径)
// 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
if(index % 2 == 0){
return $.table.imageView('http://demo.ruoyi.vip/img/profile.jpg');

@ -35,7 +35,7 @@
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
<div class="hide" th:text="个人中心"></div>
<div class="pull-left image">
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}" class="img-circle" alt="User Image">
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="img-circle" alt="User Image">
</div>
</a>
<div class="pull-left info">
@ -173,7 +173,7 @@
<li><a title="全屏显示" href="javascript:void(0)" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏显示</a></li>
<li class="dropdown user-menu">
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}" class="user-image">
<img th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}" class="user-image">
<span class="hidden-xs">[[${user.userName}]]</span>
</a>
<ul class="dropdown-menu">

@ -30,7 +30,7 @@ $(window).load(function() {
var options = {
thumbBox: '.thumbBox',
spinner: '.spinner',
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + 'profile/avatar/' + avatar
imgSrc: $.common.isEmpty(avatar) ? ctx + 'img/profile.jpg' : ctx + avatar.substr(1)
}
cropper = $('.imageBox').cropbox(options);
$('#avatar').on('change', function() {

@ -15,7 +15,7 @@
</div>
<div class="ibox-content">
<div class="text-center">
<p><img class="img-circle img-lg" th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{/profile/avatar/} + ${user.avatar}"></p>
<p><img class="img-circle img-lg" th:src="(${user.avatar} == '') ? @{/img/profile.jpg} : @{${user.avatar}}"></p>
<p><a href="javascript:avatar()">修改头像</a></p>
</div>
<ul class="list-group list-group-striped">

@ -113,7 +113,8 @@ public class FileUploadUtils
File desc = getAbsoluteFile(baseDir, fileName);
file.transferTo(desc);
return fileName;
String pathFileName = StringUtils.substringAfterLast(baseDir, ":") + fileName;
return pathFileName;
}
/**
@ -230,5 +231,4 @@ public class FileUploadUtils
}
return extension;
}
}
Loading…
Cancel
Save