update ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java.

pull/319/head
Hacker 3 years ago committed by Gitee
parent 4142a733b8
commit e8782ab4bf

@ -103,19 +103,18 @@ public class CommonController
{ {
// 上传文件路径 // 上传文件路径
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
String fileNames = ""; List<String> fileNames = new ArrayList<>();
String urls = ""; List<String> urls = new ArrayList<>();
for (MultipartFile file : files) for (MultipartFile file : files) {
{
// 上传并返回新文件名称 // 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
fileNames += fileName + FILE_DELIMETER; fileNames.add(fileName);
urls += url + FILE_DELIMETER; urls.add(url);
} }
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("fileNames", StringUtils.lastStringDel(fileNames, FILE_DELIMETER)); ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("urls", StringUtils.lastStringDel(urls, FILE_DELIMETER)); ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
return ajax; return ajax;
} }
catch (Exception e) catch (Exception e)

Loading…
Cancel
Save