本文共 902 字,大约阅读时间需要 3 分钟。
引入相关bootstrap文件链接
编写前台代码
<#include "../common/header.ftl"><#include "../common/nav.ftl"> <#--上传文件区域-->
后台接收图片,并存入本地
@PostMapping("/uploadImages")@ResponseBodypublic String uploadImages(HttpServletRequest request,MultipartFile file){ try{ String filename = file.getOriginalFilename(); //上传的路径 String path = "d:\\upload"; filename = changeName(filename); String rappendix = "upload/" + filename; filename = path + "\\" + filename; File file1 = new File(filename); file.transferTo(file1); String str = "{\"src\":\"" + rappendix + "\"}"; return str; }catch (Exception e){ throw new AuthorizationException("上传文件失败"); }}
效果如下:
选中两个文件