Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Z
zhgh
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
Zhou Yang
zhgh
Commits
502764fb
Commit
502764fb
authored
Mar 27, 2019
by
xiujunlian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传图片重命名
parent
c0739901
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
15 deletions
+40
-15
JgSubjectController.java
.../java/com/hmit/kernes/controller/JgSubjectController.java
+13
-2
SysOssController.java
...ain/java/com/hmit/kernes/controller/SysOssController.java
+15
-3
organization.html
...uts-web/src/main/webapp/WEB-INF/page/jk/organization.html
+1
-4
organization.js
beansprouts-web/src/main/webapp/js/jk/organization.js
+11
-6
No files found.
beansprouts-web/src/main/java/com/hmit/kernes/controller/JgSubjectController.java
View file @
502764fb
...
...
@@ -11,6 +11,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -220,17 +221,27 @@ public class JgSubjectController extends AbstractController {
//String url = request.getSession().getServletContext().getRealPath("doc/");
String
url
=
"C:/document/doc"
;
String
newFileName
=
""
;
if
(
file
.
isEmpty
())
{
throw
new
RRException
(
"上传文件不能为空"
);
}
try
{
url
=
url
.
replaceAll
(
"/"
,
"\\\\"
);
String
fileName
=
file
.
getOriginalFilename
();
int
i
=
fileName
.
lastIndexOf
(
"."
);
String
newext
=
fileName
.
substring
(
i
);
SimpleDateFormat
simpleDateFormat
;
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd_hhmmss"
);
Date
date
=
new
Date
();
newFileName
=
"图片_"
+
simpleDateFormat
.
format
(
date
)+
"_"
+
file
.
getSize
()+
newext
;
File
file3
=
new
File
(
url
);
if
((!
file3
.
exists
())
&&
(!
file3
.
isDirectory
()))
{
file3
.
mkdir
();
}
File
file2
=
new
File
(
file3
,
f
ileName
);
File
file2
=
new
File
(
file3
,
newF
ileName
);
InputStream
in
=
file
.
getInputStream
();
FileOutputStream
fos
=
new
FileOutputStream
(
file2
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
fos
);
...
...
@@ -246,7 +257,7 @@ public class JgSubjectController extends AbstractController {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
R
.
ok
();
return
R
.
ok
()
.
put
(
"filename"
,
newFileName
)
;
}
/**
...
...
beansprouts-web/src/main/java/com/hmit/kernes/controller/SysOssController.java
View file @
502764fb
...
...
@@ -5,6 +5,8 @@ import java.io.File;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -25,16 +27,26 @@ public class SysOssController {
@RequestMapping
(
"/ToLeadImg"
)
public
R
ToLeadImg
(
String
editorid
,
@RequestParam
(
"upfile"
)
MultipartFile
file
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
String
path
=
""
;
String
newFileName
=
""
;
try
{
//path = request.getSession().getServletContext().getRealPath("statics/plugins/umeditor/docroot/attachments/article/");
path
=
"C:/document/attachments/"
;
path
=
path
.
replaceAll
(
"/"
,
"\\\\"
);
String
fileName
=
file
.
getOriginalFilename
();
String
fileName
=
file
.
getOriginalFilename
();
int
i
=
fileName
.
lastIndexOf
(
"."
);
String
newext
=
fileName
.
substring
(
i
);
SimpleDateFormat
simpleDateFormat
;
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd_hhmmss"
);
Date
date
=
new
Date
();
newFileName
=
"图片_"
+
simpleDateFormat
.
format
(
date
)+
"_"
+
file
.
getSize
()+
newext
;
File
file3
=
new
File
(
path
);
if
((!
file3
.
exists
())
&&
(!
file3
.
isDirectory
()))
{
file3
.
mkdir
();
}
File
file2
=
new
File
(
file3
,
f
ileName
);
File
file2
=
new
File
(
file3
,
newF
ileName
);
InputStream
in
=
file
.
getInputStream
();
FileOutputStream
fos
=
new
FileOutputStream
(
file2
);
BufferedOutputStream
bos
=
new
BufferedOutputStream
(
fos
);
...
...
@@ -50,7 +62,7 @@ public class SysOssController {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
R
.
ok
().
put
(
"url"
,
"docroot/attachments/article/"
+
file
.
getOriginalFilename
()
);
return
R
.
ok
().
put
(
"url"
,
"docroot/attachments/article/"
+
newFileName
);
}
@RequestMapping
(
"/ToLead"
)
public
String
imgController
(
Map
<
String
,
Object
>
params
)
{
...
...
beansprouts-web/src/main/webapp/WEB-INF/page/jk/organization.html
View file @
502764fb
...
...
@@ -182,8 +182,7 @@
<div
class=
"form-group"
>
<div
class=
"col-sm-2 control-label"
>
附件
</div>
<div
class=
"col-sm-10"
>
<el-upload
class=
"upload-demo"
<el-upload
class=
"upload-demo"
action=
"../jk/jgsubject/uploadfile"
:on-exceed=
"handleExceed"
:on-preview=
"handlePreview"
...
...
@@ -195,8 +194,6 @@
<el-button
size=
"small"
type=
"primary"
>
点击上传
</el-button>
<div
slot=
"tip"
class=
"el-upload__tip"
>
只能上传10个文件,且单个文件不超过10M
</div>
</el-upload>
<!--<input type="text" class="form-control" v-model="jgSubject.file" style="display:none"/>
<div id="file" class="dropzone" style="border: 1px solid #ccc;width:300px;height:30px;float: left;"></div>-->
</div>
</div>
<div
class=
"form-group"
>
...
...
beansprouts-web/src/main/webapp/js/jk/organization.js
View file @
502764fb
...
...
@@ -80,13 +80,16 @@ $(function () {
this
.
on
(
"addedfile"
,
function
(
file
)
{
});
this
.
on
(
"success"
,
function
(
file
)
{
photo
=
file
.
name
;
this
.
on
(
"success"
,
function
(
file
,
data
)
{
console
.
log
(
data
)
console
.
log
(
file
)
photo
=
data
.
filename
;
isUsedPhotoOrFile
=
true
;
});
this
.
on
(
"removedfile"
,
function
(
file
)
{
var
fileName
=
file
.
name
;
remove
(
fileName
)
photo
=
null
;
//var fileName = file.name;
//remove(fileName)
});
}
});
...
...
@@ -107,8 +110,8 @@ $(function () {
isUsedPhotoOrFile
=
true
;
});
this
.
on
(
"removedfile"
,
function
(
file
)
{
var
fileName
=
file
.
name
;
remove
(
fileName
)
//
var fileName = file.name;
//
remove(fileName)
});
}
});
...
...
@@ -210,6 +213,7 @@ var vm = new Vue({
vm
.
reload
();
},
add
:
function
(){
vm
.
fileList
=
[];
isUsedPhotoOrFile
=
false
;
vm
.
showList
=
false
;
vm
.
title
=
"新增"
;
...
...
@@ -355,6 +359,7 @@ var vm = new Vue({
});
},
reload
:
function
(
event
)
{
vm
.
fileList
=
[];
if
(
isUsedPhotoOrFile
){
window
.
location
.
reload
();
}
...
...
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