if(imgFile!=null){Filesavefile=newFile(newFile(savePath),imgN);if(!savefile.getParentFile().exists()){savefile.getParentFile().mkdirs();try{FileUtils.copyFile(imgFile,sav...
if (imgFile != null) {
File savefile = new File(new File(savePath), imgN);
if (!savefile.getParentFile().exists()) {
savefile.getParentFile().mkdirs();
try {
FileUtils.copyFile(imgFile, savefile);
map.put("error", 0);
map.put("url", savefile);
JSONObject json = JSONObject.fromObject(map);
response.getOutputStream().print(json.toString());
} catch (IOException e) {
e.printStackTrace();
}
} else {
try {
FileUtils.copyFile(imgFile, savefile);
map.put("url", savefile);
map.put("error", 0);
JSONObject json = JSONObject.fromObject(map);
System.out.println(json);
response.getOutputStream().print(json.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
} else {
map.put("error", 1);
map.put("message", "上传失败");
JSONObject json = JSONObject.fromObject(map);
try {
response.getOutputStream().print(json.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
展开