Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
Project
Project
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
licc
shop-Mall
Commits
d6edcef3
Commit
d6edcef3
authored
Mar 11, 2021
by
m1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资讯模块数据——修改图片地址出现null问题
parent
39c85355
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
2 deletions
+4
-2
UploadServiceImpl.java
...java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
+4
-2
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
View file @
d6edcef3
...
...
@@ -42,7 +42,7 @@ public class UploadServiceImpl implements UploadService {
@Autowired
private
UsersMapper
usersMapper
;
@Value
(
"${file.upload.path:#{null}}"
)
//
@Value("${file.upload.path:#{null}}")
private
String
path
;
/**
...
...
@@ -152,10 +152,10 @@ public class UploadServiceImpl implements UploadService {
public
List
imageUpload
(
MultipartFile
[]
files
,
String
zxField
,
String
zxAddress
,
String
inviteCode
)
{
//获取上传图片数量,打印在控制台
System
.
out
.
println
(
"上传图片数量"
+
files
.
length
);
String
zxUrl
=
new
String
();
//创建集合
List
<
Map
<
String
,
Object
>>
root
=
new
ArrayList
<
Map
<
String
,
Object
>>();
String
fileName1
=
null
;
String
zxUrl
=
null
;
// 要上传的目标文件存放的绝对路径
// final String localPath = path;
Long
time
=
new
Date
().
getTime
();
...
...
@@ -167,6 +167,7 @@ public class UploadServiceImpl implements UploadService {
if
(
file
.
isEmpty
())
{
System
.
out
.
println
(
"上传图片为空,请重新上传"
);
}
//判断上传文件格式
String
fileType
=
file
.
getContentType
();
if
(
fileType
.
equals
(
"image/jpeg"
)
||
fileType
.
equals
(
"image/png"
))
{
...
...
@@ -181,6 +182,7 @@ public class UploadServiceImpl implements UploadService {
//设置文件存储路径,可以存放在你想要指定的路径里面
String
Path
=
"/opt/upload/video/"
;
//上传图片存放位置
zxUrl
+=
localPath
+
fileName
+
","
;
if
(
FileUtils
.
upload
(
file
,
Path
,
fileName
))
{
//文件存放的相对路径(一般存放在数据库用于img标签的src)
String
relativePath
=
"用于判断是否图片上传成功,返回值有:"
+
fileName
;
...
...
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