一、后台代码
@RequestMapping(value = "/upload",method = {
RequestMethod.POST},headers = "content-type=multipart/form-data")
@ApiOperation(value = "图上传" )
@ApiImplicitParam(name = file,value = "文件对象的名字",required = true,paramType = "body")
public AjaxResult electronicBookUpLoad(@RequestPart(value = "file",required = true) MultipartFile file) throws IOException
{
if (!file.isEmpty())
{
//获取文件上传路径
String electronicBookUrl = FileUploadUtils.upload(RuoYiConfig.getCellTpPath(), file);
String url = serverConfig.getUrl() + electronicBookUrl;
AjaxResult ajax = AjaxResult.success();
//返回文件地址
ajax.put("file", electronicBookUrl);
ajax.put("url", url);
return ajax;
}
return AjaxResult.error("上传图谱异常,请联系管理员");
}
二、前台代码
vue结合element-ui
<imageUpload v-model="imageUrl" :toImageUrl="imageUrl"/>