cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cn.ksource.web.controller.business.component;
 
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
import cn.ksource.core.util.FileUtil;
import cn.ksource.core.util.JsonUtil;
import cn.ksource.core.web.WebUtil;
import cn.ksource.web.util.ImgCompress;
 
@Controller
@RequestMapping("/interface/fileupload")
public class FileUploadInterfacenewController {
 
    @RequestMapping("picpressupload.html")
    public void onFileUpload(HttpServletRequest request,HttpServletResponse response) throws IOException{
        //保存合同附件
        List<FileUtil.FileInfo> iconPath = null;
        try {
            iconPath = FileUtil.uploadFiles(request, "/upload/infofiles/", null);
            String savePath = iconPath.get(0).getFilePath();
            System.out.println("-----------------"+savePath);
            String tmpPath = request.getSession().getServletContext().getRealPath("/")+savePath;
            ImgCompress imgCom = new ImgCompress(tmpPath);
            imgCom.resizeFix(tmpPath,400, 400);
            Map dirMap = new HashMap();
            dirMap.put("FILE_PATH", savePath);
            WebUtil.write(response, JsonUtil.map2Json(dirMap)); 
            
            
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        /*if (iconPath != null ) {
            Map fileMap = new HashMap();
            for (FileUtil.FileInfo fileInfo : iconPath) {
                fileMap.put("EXT_NAME", fileInfo.getExtName());
                fileMap.put("FIELD_NAME", fileInfo.getFieldName());
                fileMap.put("FILE_PATH", fileInfo.getFilePath());
                fileMap.put("FILE_SIZE", fileInfo.getFileSize());
                fileMap.put("FILE_NAME", fileInfo.getOriginalFilename());
            }
            WebUtil.write(response, JsonUtil.map2Json(fileMap));
            PrintWriter out = response.getWriter();
            out.println(tmpPath);
            out.flush();
        }*/
        //WebUtil.write(response, JsonUtil.map2Json(t)); 
    }
    
}