1返回Json的信息:
//成功时 { "error" : 0, "url" : "http://www.example.com/path/to/file.ext" }
//失败时 { "error" : 1, "message" : "错误信息" }
后台代码:
//成功时 { "error" : 0, "url" : "http://www.example.com/path/to/file.ext" }
//失败时 { "error" : 1, "message" : "错误信息" }
后台代码:
@RequestMapping(value = "uoload")
@ResponseBody
public String uoload(HttpServletRequest request,HttpServletResponse response,
@RequestParam MultipartFile imgFile) throws Exception {
//String savePath = request.getRealPath("/") + "attached/";
String savePath = FastDFSUtil.upload(imgFile.getBytes(), "gif");
return "{ \"error\" : 0, \"url\" : \""+urlPrefix+savePath+"\" }";
}