mirror of https://gitee.com/y_project/RuoYi.git
上传文件修改为返回完整路径
parent
8dfa1834e3
commit
304da21e6d
|
@ -27,11 +27,6 @@ public class CommonController
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件上传路径
|
|
||||||
*/
|
|
||||||
public static final String UPLOAD_PATH = "/profile/upload/";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServerConfig serverConfig;
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
|
@ -82,7 +77,7 @@ public class CommonController
|
||||||
String filePath = Global.getUploadPath();
|
String filePath = Global.getUploadPath();
|
||||||
// 上传并返回新文件名称
|
// 上传并返回新文件名称
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
String url = serverConfig.getUrl() + UPLOAD_PATH + fileName;
|
String url = serverConfig.getUrl() + fileName;
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("fileName", fileName);
|
ajax.put("fileName", fileName);
|
||||||
ajax.put("url", url);
|
ajax.put("url", url);
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
{
|
{
|
||||||
title: '图片',
|
title: '图片',
|
||||||
formatter: function(value, row, index) {
|
formatter: function(value, row, index) {
|
||||||
// 图片自由组合(注意:如存储在本地需要带上 '/profile/upload' + 数据库路径)
|
// 图片预览(注意:如存储在本地直接获取数据库路径,如有配置context-path需要使用ctx+路径)
|
||||||
// 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
|
// 如:/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
|
||||||
if(index % 2 == 0){
|
if(index % 2 == 0){
|
||||||
return $.table.imageView('http://demo.ruoyi.vip/img/profile.jpg');
|
return $.table.imageView('http://demo.ruoyi.vip/img/profile.jpg');
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
|
<a class="menuItem" title="个人中心" th:href="@{/system/user/profile}">
|
||||||
<div class="hide" th:text="个人中心"></div>
|
<div class="hide" th:text="个人中心"></div>
|
||||||
<div class="pull-left image">
|
<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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<div class="pull-left info">
|
<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><a title="全屏显示" href="javascript:void(0)" id="fullScreen"><i class="fa fa-arrows-alt"></i> 全屏显示</a></li>
|
||||||
<li class="dropdown user-menu">
|
<li class="dropdown user-menu">
|
||||||
<a href="javascript:void(0)" class="dropdown-toggle" data-hover="dropdown">
|
<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>
|
<span class="hidden-xs">[[${user.userName}]]</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
|
|
@ -30,7 +30,7 @@ $(window).load(function() {
|
||||||
var options = {
|
var options = {
|
||||||
thumbBox: '.thumbBox',
|
thumbBox: '.thumbBox',
|
||||||
spinner: '.spinner',
|
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);
|
cropper = $('.imageBox').cropbox(options);
|
||||||
$('#avatar').on('change', function() {
|
$('#avatar').on('change', function() {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
<div class="text-center">
|
<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>
|
<p><a href="javascript:avatar()">修改头像</a></p>
|
||||||
</div>
|
</div>
|
||||||
<ul class="list-group list-group-striped">
|
<ul class="list-group list-group-striped">
|
||||||
|
|
|
@ -113,7 +113,8 @@ public class FileUploadUtils
|
||||||
|
|
||||||
File desc = getAbsoluteFile(baseDir, fileName);
|
File desc = getAbsoluteFile(baseDir, fileName);
|
||||||
file.transferTo(desc);
|
file.transferTo(desc);
|
||||||
return fileName;
|
String pathFileName = StringUtils.substringAfterLast(baseDir, ":") + fileName;
|
||||||
|
return pathFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -230,5 +231,4 @@ public class FileUploadUtils
|
||||||
}
|
}
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue