/* * 对表单上传的文件进行改名 */ private String getNewFilename(String s){ int i = s.indexOf("."); String s1 = s.substring(i+1,s.length()); java.util.Date today = new java.util.Date(); String str =""; //SimpleDateFormat他在java.text包下面,作用是把一个data对象转换成我们想要的字符串 SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSS"); str = formatter.format(today); return str+"."+s1; }
/* ******************** 文件上传 *************************** */ FormFile file = ef.getFile(); String Savefilepath = "" ; String Savefilename = "" ; if (!( file.getFileName()).equals("")) { try { InputStream stream = file.getInputStream();//把文件读入 Savefilepath = request.getRealPath("/upload");//将文件存放在当前系统路径的哪个文件夹下 Savefilename = getNewFilename(file.getFileName()); Savefilepath = Savefilepath + "\\" + Savefilename; //将文件名存入数据库 empl.setRemark(Savefilename); OutputStream bos = new FileOutputStream(Savefilepath);//建立一个上传文件的输出流 int bytesRead = 0; byte[] buffer = new byte[10*1024]; while ( (bytesRead = stream.read(buffer, 0, 10240)) != -1) { bos.write(buffer, 0, bytesRead);//将文件写入服务器的硬盘上 } bos.close(); stream.close(); }catch(Exception e){ e.printStackTrace(); } } /* ******************** 文件上传 *************************** */<td><IMG width="100" height="100" src="photo/<%=e.getRemark()%>"> </td>
String content = ds.toGBK(ds.toString((String)request.getParameter("content")));
<object classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 width=450 height=400><param name=showstatusbar value=1><param name=filename value='../video/upload/<%=sp%>'><embed src='/news/upload/1.wmv'></embed></object>
jdbc:oracle:thin:@192.168.0.13:1521:dbstudy
oracle.jdbc.driver.OracleDriver