Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gdtel-gztel-school-center
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴学德
gdtel-gztel-school-center
Commits
a09b3090
Commit
a09b3090
authored
Oct 19, 2020
by
黎配弘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
尝试修复路径遍历
parent
0442250b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
14 deletions
+37
-14
common/src/main/java/com/winsun/utils/FileUtil.java
+4
-4
service-manager/src/main/java/com/winsun/controller/PackageController.java
+0
-0
service-manager/src/main/java/com/winsun/controller/SchoolManagementController.java
+33
-10
No files found.
common/src/main/java/com/winsun/utils/FileUtil.java
View file @
a09b3090
...
...
@@ -17,7 +17,7 @@ import java.io.OutputStream;
public
class
FileUtil
{
//写到相应路径
public
static
boolean
makefile
(
String
path
,
MultipartFile
file
,
String
filename
){
/*
public static boolean makefile(String path, MultipartFile file,String filename){
File dir = new File(path);
if (!dir.exists()) {
...
...
@@ -40,9 +40,9 @@ public class FileUtil {
}
}
return true;
}
}
*/
public
static
boolean
makefile1
(
String
path
,
MultipartFile
file
,
String
filename
){
/*
public static boolean makefile1(String path, MultipartFile file,String filename){
File dir = new File(path);
if (!dir.exists()) {
dir.mkdirs();
...
...
@@ -62,5 +62,5 @@ public class FileUtil {
}
}
return true;
}
}
*/
}
service-manager/src/main/java/com/winsun/controller/PackageController.java
View file @
a09b3090
This diff is collapsed.
Click to expand it.
service-manager/src/main/java/com/winsun/controller/SchoolManagementController.java
View file @
a09b3090
...
...
@@ -29,6 +29,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -244,17 +247,37 @@ public class SchoolManagementController extends BaseController {
@Permission
(
menuname
=
"上传二维码"
,
value
=
"qrcodeUpload"
,
method
=
RequestMethod
.
POST
)
public
ResponseData
<
String
>
xiaotuUpload
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
,
@RequestParam
(
value
=
"id"
,
required
=
false
)
String
id
)
{
String
backgroundpath
=
FilePath
.
BACKGROUNDIMG
.
getValue
()+
"/"
+
DEFAULTPATH
;
boolean
makefile
=
FileUtil
.
makefile
(
backgroundpath
,
file
,
id
+
FILENAME
);
Wrapper
<
School
>
wrapper
=
new
EntityWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"service_qrcode"
,
backgroundpath
+
id
+
FILENAME
);
Integer
integer
=
schoolMapper
.
updateForSet
(
MyBatisPlusUpdateUtils
.
toUpdateSet
(
map
),
wrapper
);
if
(
integer
!=
1
){
return
ResponseData
.
error
(
"上传失败!"
);
String
backgroundpath
=
FilePath
.
BACKGROUNDIMG
.
getValue
()
+
"/"
+
DEFAULTPATH
;
File
dir
=
new
File
(
backgroundpath
);
if
(!
dir
.
exists
())
{
dir
.
mkdirs
();
}
File
savePath
=
new
File
(
backgroundpath
,
id
+
FILENAME
);
OutputStream
os
=
null
;
try
{
os
=
new
FileOutputStream
(
savePath
);
os
.
write
(
file
.
getBytes
());
os
.
flush
();
Wrapper
<
School
>
wrapper
=
new
EntityWrapper
<>();
wrapper
.
eq
(
"id"
,
id
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"service_qrcode"
,
backgroundpath
+
id
+
FILENAME
);
Integer
integer
=
schoolMapper
.
updateForSet
(
MyBatisPlusUpdateUtils
.
toUpdateSet
(
map
),
wrapper
);
if
(
integer
!=
1
){
return
ResponseData
.
error
(
"上传失败!"
);
}
return
ResponseData
.
success
(
"上传成功"
);
}
catch
(
Exception
e
)
{
log
.
error
(
"上传文件失败:"
+
e
.
getMessage
(),
e
);
return
ResponseData
.
error
(
"上传失败"
+
e
.
getMessage
());
}
finally
{
if
(
os
!=
null
)
{
try
{
os
.
close
();
}
catch
(
Exception
e
)
{}
}
}
return
ResponseData
.
success
(
"上传成功"
);
}
...
...
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