Upload multiple files

<div class="easyui-layout" style="width:100%;height:100%;">
<div data-options="region:'west',split:true" style="width:100%;">
<form class="form-horizontal" id="fileform" name="fileform" method="post" enctype="multipart/form-data" action="applyLoans/submitphone" style="margin: 0;padding: 10px" >
<div class="col-md-12" style="margin-bottom: 20px">
<label class="easylabel lb-70" >选择文件<font color="#FF0000">*</font></label>
<input id="file_url" name="file_url" buttonText="选择文件" required="true" class="easyui-filebox" type="file" style="filewidth: 100%">
</div>
<input type="submit" value="sss"/>
</form>
</div>
</div>


/ **
* Upload packaging method
*
* @param Request
* @param LoanID
* @return
* @throws Exception
* /
public the Map <String, Object> Upload (a MultipartHttpServletRequest Request, int LoanID) throws Exception {
String filePath = "";
String = osskey "";
the Map <String, Object> = new new Map the HashMap <> ();
// extract upload
the Map <String, a MultipartFile> files = request.getFileMap ();
// file upload control comprising determining whether
if (files .size ()> 0) {
// definition can upload files of type
List <String> filelimit = Arrays.asList ( "JPG", "GIF", "PNG");
the Map <String, String> = new new filelimitmap the HashMap < > ();
filelimit.forEach((s) -> filelimitmap.put(s, s));
SET <String> = files.keySet Keys ();
// iterate set
for (String Key: Keys) {
// is determined for multiple file upload
List <a MultipartFile> = request.getFiles the fileList (Key);
// file to determine whether there
if (fileList.size () == 0) {
Continue;
}
the StringBuilder the StringBuilder new new STR = ();
String filename = "";
// uploaded through the collection
for (a MultipartFile file: the fileList) {
// if the file is determined
if (. file.getOriginalFilename () length () <=. 1) {
Continue;
}
int ID = 0;
// determines whether the file format of limitation
filename = file.getOriginalFilename ();
int lastIndexOf = filename.lastIndexOf ( ".");
String = filename.substring S (+ lastIndexOf. 1);
IF (filelimitmap.get (S) = null =) {
Continue;
}
// return oss. 1 put on the Key.
osskey = OSS.uploadImage (file.getInputStream ());
. 2 // return a discharge path is stored again sftp file_data
filePath = SFTP.addFile (File. getInputStream (), LoanID, file.getOriginalFilename (), osskey);
map.put ( "osskey", osskey); // Ali cloud Key oss
map.put ( "filePath", filePath); // sftp return path
map.put("fileName", filename);
map.put("ext", s);
id = adminDao.submitFileData(map);
System.out.println("返回的id" + id);
str.append(id + ",");
}
String strid = "" + str;
map.put(key, strid);
}
}
return map;
}

Guess you like

Origin www.cnblogs.com/zhou-tt/p/12100830.html