SmartUpload上传

<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <%@ page import="com.jspsmart.upload.*" %> <%@ page import="DBstep.iDBManager2000.*"%> <% //实例化上载bean com.jspsmart.upload.SmartUpload mySmartUpload=new com.jspsmart.upload.SmartUpload(); //初始化 mySmartUpload.initialize(pageContext); //设置上载的最大值 mySmartUpload.setMaxFileSize(500 * 1024*1024); //上载文件 mySmartUpload.upload(); //循环取得所有上载的文件 for (int i=0;i<mysmartupload.getfiles().getcount();i++){ 取得上载的文件="" com.jspsmart.upload.file="" myfile="mySmartUpload.getFiles().getFile(i);" if="" (!myfile.ismissing())="" {="" 取得上载的文件的文件名="" string="" myfilename="myFile.getFileName();" 取得不带后缀的文件名="" string="" suffix="myFileName.substring(0,myFileName.lastIndexOf('.'));" 取得后缀名="" string="" ext="mySmartUpload.getFiles().getFile(0).getFileExt();" 取得文件的大小="" int="" filesize="myFile.getSize();" 保存路径="" string="" aa="getServletContext().getRealPath(&quot;/&quot;)+&quot;jsp\&quot;;" string="" trace="aa+myFileName;" 取得别的参数="" string="" explain="(String)mySmartUpload.getRequest().getParameter(&quot;text&quot;);" string="" send="(String)mySmartUpload.getRequest().getParameter(&quot;send&quot;);" 将文件保存在服务器端="" myfile.saveas(trace,mysmartupload.save_physical);="" 下面的是将上载的文件保存到数据库中="" 将文件读到流中="" java.io.file="" file="new" java.io.file(trace);="" java.io.fileinputstream="" fis="new" java.io.fileinputstream(file);="" out.println(file.length());="" 打开数据库="" resultset="" result="null;" string="" msql="null;" preparedstatement="" prestmt="null;" dbstep.idbmanager2000="" dbaobj="new" dbstep.idbmanager2000();="" dbaobj.openconnection();="" 将文件写到数据库中="" msql="insert into marklist (markname,password,marksize,markdate,MarkBody) values (?,?,?,?,?)" ;="" prestmt="DbaObj.Conn.prepareStatement(mSql);" prestmt.setstring(1,="" "aaa1");="" prestmt.setstring(2,="" "0000");="" prestmt.setint(3,="" filesize);="" prestmt.setstring(4,="" dbaobj.getdatetime());="" prestmt.setbinarystream(5,fis,(int)file.length());="" dbaobj.conn.setautocommit(true)="" ;="" prestmt.executeupdate();="" dbaobj.conn.commit();="" out.println(("上载成功!!!").tostring());="" }="" else="" {="" out.println(("上载失败!!!").tostring());="" }="" }="" 与前面的if对应="" %="">

你可能感兴趣的:(java,sql,jsp,bean,ext)