/* At this point the application doesn't actually associate the images with a portfolio. This just saves the file to the filesystem */
private void addImage ( File pic, String fileName, String fileSystemHome ) throws IOException
{
/* add image to the portfolio and save image file to local filesystem */
FileInputStream in = null;
FileOutputStream out = null;
String directoryName = fileSystemHome;
String localPath=getRequest().getSession().getServletContext().getRealPath("/");
File dir = new File ( localPath+directoryName);
boolean b=false;
if ( !dir.exists() ){
b=dir.mkdirs();
}
String targetPath = dir.getPath() + dir.separator + fileName;
File picDestination = new File ( targetPath);
try {
in = new FileInputStream( pic );
out = new FileOutputStream( picDestination );
int c;
while ((c = in.read()) != -1) {
out.write(c);
}
}finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
if(caseId>0){
fileSystemPath="page/videoManage/pic";
//String picTime=fileSystemPath+"/"+getUploadPicFileName().substring(0,6 );
String picTime=fileSystemPath+"/"+getUploadPicFileName().substring(0,6 )+"/"+String.valueOf(caseId)+"/before";
try {
addImage( getUploadPic(), getUploadPicFileName(), picTime );
} catch (IOException e) {
this.addFieldError("OpErr", "上传视频截图失败,请查看异常日志");
return "err";
}
try{
caseImage.setId(getUploadPicFileName().substring(0, getUploadPicFileName().indexOf(".")));
caseImage.setCaseId(caseId);
caseImage.setImageUrl(picTime+"/"+getUploadPicFileName());
caseImage.setCaseType(0);
caseImage.setImageType(1);
Long ong=caseInfoBS.addCaseImage(caseImage);
}catch (Exception e) {
this.addFieldError("OpErr", "添加视频截图到数据库失败,请查看异常日志");
return "err";
}
// try {
// this.getResponse().getWriter().write("案件保存成功");
// } catch (IOException e) {
// e.printStackTrace();
// }
ActionContext.getContext().put("resultBoolean", "1");
}