@Controller
@RequestMapping("/upload")
public class FileUpload extends BaseController {
@ResponseBody
@RequestMapping("/img")
public Map<String,Object> uploadImg(HttpServletRequest request,Integer root) throws IOException{
String basePath = request.getContextPath();
Map<String,Object> result = new HashMap<String, Object>();
result.put("error",0);
if(!Toolkit.isEmpty(root)){
result.put("url",UploadFileUtil.saveLocalImage(request, SysPropertiesCache.getValue("imgPath"),false, null, null));
}else{
result.put("url",basePath+UploadFileUtil.saveLocalImage(request, SysPropertiesCache.getValue("imgPath"),false, null, null));
}
return result;
}
@ResponseBody
@RequestMapping("/file")
public ResultEntity<Object> uploadFile(HttpServletRequest request,String fileName) throws IOException{
ResultEntity<Object> result = new ResultEntity<Object>();
String filePath = (SysPropertiesCache.getValue("filePath")+"/").replaceAll("//","/");
result.setStatus(success);
result.setData(UploadFileUtil.saveLocalFile(request, filePath,fileName));
return result;
}