String pptpath = request.getRealPath("scwd");//路径
//关键点,关于数组类型,struts会保存为Hashtable
Hashtable fileh = form.getMultipartRequestHandler().getFileElements();
String dypptList="";
String realpptList="";
for (Iterator it = fileh.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
//得到附件,jsp页面中表单域的名称不能相同,否则只能得到最后一个附件
FormFile ff = (FormFile) fileh.get(key);
String dyppt = ff.getFileName(); //获取上传文件名
if (!"".equals(dyppt)&&null!=dyppt) {
if ((!fileLastName(dyppt).equals("jpg"))&&(!fileLastName(dyppt).equals("JPG"))&&(!fileLastName(dyppt).equals("bmp"))&&(!fileLastName(dyppt).equals("BMP")))
{
JsonUtil.outInfo(response, "请选择jpg或bmp格式图片", true);
return;
}
String sjc = doDate();
dypptList+=dyppt+";";
realpptList+=sjc+oper_id+dyppt.substring(dyppt.indexOf("."), dyppt.length())+";";
//多文件上传
if(null!=t.getDyppt()&&!"".equals(t.getDyppt())) t.setDyppt(t.getDyppt()+";"+dyppt);//文件名称
else t.setDyppt(dyppt);//文件名称
if(null!=t.getRealppt()&&!"".equals(t.getRealppt())) t.setRealppt(t.getRealppt()+";"+sjc+oper_id+dyppt.substring(dyppt.indexOf("."), dyppt.length()));//真实文件名称
else t.setRealppt(sjc+oper_id+dyppt.substring(dyppt.indexOf("."), dyppt.length()));//真实文件名称
t.setPptpath(pptpath);//路径
//进行文档操作
if(ff!=null&&!StrUtil.strnull(ff.getFileName()).equals("")){
try{
InputStream stream = ff.getInputStream();
OutputStream bos = new FileOutputStream(pptpath + "/"+ sjc+oper_id+dyppt.substring(dyppt.indexOf("."), dyppt.length()));
System.out.println(pptpath + "/"+ sjc+oper_id+dyppt.substring(dyppt.indexOf("."), dyppt.length()));
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
bos.write(buffer, 0, bytesRead);
}
bos.close();
stream.close();
}catch(Exception e){
e.printStackTrace();
au.setInfo(au.getInfo()+"文档操作错误:"+e.getMessage());
}
request.setAttribute("sheet_no", sheet_no);
request.setAttribute("msg", au.getFlag());
//request.setAttribute("info", au.getInfo().toString());
}
}else{
continue;
}
}