Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
304da21e
Commit
304da21e
authored
Jul 11, 2019
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传文件修改为返回完整路径
parent
8dfa1834
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
14 deletions
+10
-14
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
+1
-6
ruoyi-admin/src/main/resources/templates/demo/table/image.html
+1
-1
ruoyi-admin/src/main/resources/templates/index.html
+2
-2
ruoyi-admin/src/main/resources/templates/system/user/profile/avatar.html
+1
-1
ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html
+1
-1
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
+4
-3
No files found.
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
View file @
304da21e
...
...
@@ -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
);
...
...
ruoyi-admin/src/main/resources/templates/demo/table/image.html
View file @
304da21e
...
...
@@ -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'
);
...
...
ruoyi-admin/src/main/resources/templates/index.html
View file @
304da21e
...
...
@@ -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"
>
...
...
ruoyi-admin/src/main/resources/templates/system/user/profile/avatar.html
View file @
304da21e
...
...
@@ -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
()
{
...
...
ruoyi-admin/src/main/resources/templates/system/user/profile/profile.html
View file @
304da21e
...
...
@@ -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"
>
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
View file @
304da21e
...
...
@@ -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
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment