---
title: "KindEditor图片上传"
author: "j_will"
date: "2015-08-24T16:26:58Z"
tags: []
categories: ["Web前端"]
slug: "kindeditor"
draft: false
lastmod: "2015-08-24T16:26:14Z"
id: 2237629
url: "https://j-will.iteye.com/blog/2237629"
---

1返回Json的信息：

//成功时 { "error" : 0, "url" : "http://www.example.com/path/to/file.ext" }

//失败时 { "error" : 1, "message" : "错误信息" } 
后台代码：

```java

@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+"\" }";
    }

```