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));
|
}
|
|
}
|