ITeye博客

KindEditor图片上传

j_will · 2015-08-24 16:26 · Web前端 · Markdown

1返回Json的信息:

//成功时 { "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+"\" }";
    }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。