解析图片流
来源:互联网 发布:办公楼pert网络布线图 编辑:程序博客网 时间:2024/04/27 21:25
private AppFeedbackService appFeedbackService ;
public static final String UPLOAD="upload/";
public void setAppFeedbackService(AppFeedbackService appFeedbackService) {
this.appFeedbackService = appFeedbackService;
}
public String appFeedbackAdd() throws Exception{
Map<String, String> jsonMap = new HashMap<String, String>();String params = request().getParameter("data");
String userId = CJSON.getUserId(params);
String feedback = CJSON.getData(params,"feedback");
String img = CJSON.getData(params,"file"); //图片
String fileName = CJSON.getData(params,"fileName"); //文件名
try {
//判断文件为空
if(img==null||img==null){
jsonMap.put("code", "1");
jsonMap.put("msg", "文件为空");
CJSON.printObject(false, jsonMap);
return null;
}
//判断文件类型
String fileType = fileName.substring(fileName.lastIndexOf("."),fileName.length());
if(!".jpg".equals(fileType.toLowerCase())&&!".png".equals(fileType.toLowerCase())&&!".jpeg".equals(fileType.toLowerCase())){
jsonMap.put("code", "2");
jsonMap.put("msg", "文件格式错误");
CJSON.printObject(false, jsonMap);
return null;
}
String dateStr = new SimpleDateFormat("yyyyMMdd").format(new Date());
String realPath = ServletUtils.serverRootDirectory()+ UPLOAD + "headImg"+"/"+ dateStr+ "/";
FileUtils.mkdirs(realPath);
if(!UploadUtil.GenerateImage(img, realPath+fileName)){
jsonMap.put("code", "3");
jsonMap.put("msg", "图片上传失败");
CJSON.printObject(false, jsonMap);
return null;
}
//截取文件路径更新数据
String filePath = realPath.substring(realPath.indexOf("upload"),realPath.length())+fileName;
long id = appFeedbackService.addFeedbackApp(userId,feedback,filePath);
if(id>0){
jsonMap.put("code", "-1");
jsonMap.put("msg", "反馈成功");
CJSON.printObject(true, jsonMap);
return null;
}else{
jsonMap.put("code", "1");
jsonMap.put("msg", "反馈失败");
CJSON.printObject(false, jsonMap);
return null ;
}
} catch (Exception e) {
e.printStackTrace();
jsonMap.put("code", "2");
jsonMap.put("msg", "未知错误");
CJSON.printObject(false, jsonMap);
}
return null;
}
0 0
- 解析图片流
- 图片解析
- 图片解析
- 解析图片
- 解析 png 图片的十六进制字符流
- BitMap解析图片显示图片
- marquee 解析 图片滚动
- MTK图片解析流程
- MTK图片解析流程
- BMP图片解析
- TinyXML解析word图片
- 解析图片二维码
- cocos2dx 图片缓存解析
- dedecms 图片标签解析
- bmp图片解析
- 解析响应式图片
- 解析本地二维码图片
- BitmapFactory.Options 图片解析
- 今日头条前端面试总结
- 3
- Shell/Bash/git/github
- 如何查看电脑CPU的核心数
- error C2248: ***: 无法访问 private 成员 可能出现的错误方向
- 解析图片流
- 修改 framework 代码的经验和踩过的坑
- 继穿越火线后的又一传奇:Final Approach
- 5
- 策略模式
- jsp ----- 数据交互 继续
- PHPStorm永久激活方法及汉化方法
- ora-00205:系统找不到控制文件
- vmware kali虚拟机无法用NAT模式上网