uniapp+springboot实现图片上传服务器端
效果图
springboot后台代码
@CrossOrigin //实现跨域请求
//下面是编写接口名和请求方式
@PostMapping(value = "/uploadimg")
public CommonResult uploadimg(String woid,@RequestParam("file") MultipartFile file, HttpServletRequest request, HttpServletResponse response) throws IllegalStateException, IOException {
CommonResult result = new CommonResult();
try {
//设置文件的保存路径
//把接口放到服务器上面的话,就改成指定的目录下面
String path = uploadConfig.getUploadPath();//获取自定义文件目录
//文件命名 我这里上传之后的图片就使用了原图
String originalFilename = file.getOriginalFilenam