jspSmartUpload上传下载

时间:2015-11-05 13:21:41
【文件属性】:

文件名称:jspSmartUpload上传下载

文件大小:48KB

文件格式:DOC

更新时间:2015-11-05 13:21:41

SmartUpload

<form action="add_do.jsp" name="formlft" method="post" ENCTYPE="multipart/form-data" check(this)">

date: <input type="text" name="checkdate" size="12" readonly=true></td> type: Record:     
No. ID Reason Remark Status op
1 <input type="text" name="id1" size="8"></TD> <textarea name="reason1" rows="3" cols="14" ></textarea> <textarea name="remark1" rows="3" cols="14" ></textarea> <textarea name="op1" rows="3" cols="10" ></textarea> <input type="file" name="file1" size="10" ></TD>
2 <input type="text" name="id2" size="8"></TD> <textarea name="reason2" rows="3" cols="14"></textarea> <textarea name="remark2" rows="3" cols="14"></textarea> <textarea name="op2" rows="3" cols="10"></textarea> <input type="file" name="file2" size="10" ></TD>
3 <input type="text" name="id3" size="8"></TD> <textarea name="reason3" rows="3" cols="14"></textarea> <textarea name="remark3" rows="3" cols="14"></textarea> <textarea name="op3" rows="3" cols="10"></textarea> <input type="file" name="file2" size="10" ></TD>
 
上传附件: <input type="file" class="bginput" name="attachment_array[]"></td> 
<input type="submit" name="Submit" value="提交"></td> <input type="reset" name="reset" value="重置"></td>
</form> <%@ page import="java.text.*"%> <%long today = System.currentTimeMillis(); java.util.Date todayime = new java.util.Date(today); SimpleDateFormat formatter = new SimpleDateFormat("yyMMddHHmmss"); String todaydate = formatter.format(todayime); //新建一个SmartUpload对象 SmartUpload su = new SmartUpload(); //上传初始化 su.initialize(pageContext); //设定上传限制 //1.限制每个上传文件的最大长度。 //su.setMaxFileSize(10000); //2.限制总上传数据的长度。 //su.setTotalMaxFileSize(20000); //3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。 //su.setAllowedFilesList("doc,txt"); //4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。 su.setDeniedFilesList("exe,bat,jsp,htm,html,,"); //上传文件 su.upload(); //将上传文件全部保存到指定目录 int count = su.save("/upload"); out.println(count+"个文件上传成功!
"); String attachsourcename=""; String newfilename=""; String save=""; for (int j=0;j"); //out.println("表单项名(FieldName)"+ file.getFieldName() + ""); //out.println("文件长度(Size)" + file.getSize() + ""); //out.println("文件名(FileName)" + file.getFileName() + ""); //out.println("文件扩展名(FileExt)" + file.getFileExt() + ""); //out.println("文件全名(FilePathName)"+ file.getFilePathName() + ""); //out.println("实际路径"+ getServletContext().getRealPath("/") + ""); //out.println("下载 " + file.getFileName() + ""); //out.println("
"); //out.println(agvid); } Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); String url = "jdbc:oracle:thin:@10.20.32.87:1521:XMCSHIS"; String user = "michelle"; String password = "michelle"; Connection conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); try{ for(int i=1;i<=3;i++){ String checkdate=su.getRequest().getParameter("checkdate"); String csttype=su.getRequest().getParameter("csttype"); String cstid=su.getRequest().getParameter("" + "cstid"+i + ""); String reason=su.getRequest().getParameter("" + "reason"+i + ""); String remark=su.getRequest().getParameter("" + "remark"+i + ""); String status=su.getRequest().getParameter("" + "status"+i + ""); String op=su.getRequest().getParameter("" + "op"+i + ""); String reporter=su.getRequest().getParameter("reporter"); if(cstid.equals("")) {break;} String SQL="insert into michelle.Table1(checkdate ,type ,id,reason ,op ,remark ,attachsourcename ,newfilename ,reporter ,status )" +" values('"+checkdate+"','"+type+"',UPPER('"+id+"'),'"+reason+"','"+op+"','"+remark+"','"+attachsourcename+"','"+newfilename+"','"+reporter+"','"+status+"')"; //out.print(SQL); //out.println(11144); //stmt.executeUpdate(SQL); } out.println("保存记录成功!"); } catch(Exception ex){ out.println(" 保存记录失败!Error Info:
"+ex.getMessage()+"


返回上一页"); //out.println("sql.executeUpdate:"+ex.getMessage()); }


网友评论