HTML代码
<HTML>
<BODY BGCOLOR="white"><H1>jspSmartUpload : Sample 2</H1>
<HR><FORM METHOD="POST" ACTION="/jspsmartupload/jsp/sample2.jsp" ENCTYPE="multipart/form-data">
   <INPUT TYPE="FILE" NAME="FILE1" SIZE="50"><BR>
   <INPUT TYPE="FILE" NAME="FILE2" SIZE="50"><BR>
   <INPUT TYPE="FILE" NAME="FILE3" SIZE="50"><BR>
   <INPUT TYPE="FILE" NAME="FILE4" SIZE="50"><BR>
   <INPUT TYPE="SUBMIT" VALUE="Upload">
</FORM></BODY>
</HTML>jsp代码
<%@ page language="java" import="com.jspsmart.upload.*"%>
<jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" /><HTML>
<BODY BGCOLOR="white"><H1>jspSmartUpload : Sample 2</H1>
<HR><%

// Variables
int count=0;         // Initialization
mySmartUpload.initialize(pageContext); // Upload
mySmartUpload.upload(); // Select each file
for (int i=0;i<mySmartUpload.getFiles().getCount();i++){ // Retreive the current file
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i); // Save it only if this file exists
if (!myFile.isMissing()) { // Save the files with its original names in a virtual path of the web server       
myFile.saveAs("/upload/" + myFile.getFileName());
// myFile.saveAs("/upload/" + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL); // sample with a physical path
// myFile.saveAs("c:\\temp\\" + myFile.getFileName(), mySmartUpload.SAVE_PHYSICAL); //  Display the properties of the current file
out.println("FieldName = " + myFile.getFieldName() + "<BR>");
out.println("Size = " + myFile.getSize() + "<BR>");
out.println("FileName = " + myFile.getFileName() + "<BR>");
out.println("FileExt = " + myFile.getFileExt() + "<BR>");
out.println("FilePathName = " + myFile.getFilePathName() + "<BR>");
out.println("ContentType = " + myFile.getContentType() + "<BR>");
out.println("ContentDisp = " + myFile.getContentDisp() + "<BR>");
out.println("TypeMIME = " + myFile.getTypeMIME() + "<BR>");
out.println("SubTypeMIME = " + myFile.getSubTypeMIME() + "<BR>"); count ++; } } // Display the number of files which could be uploaded 
out.println("<BR>" + mySmartUpload.getFiles().getCount() + " files could be uploaded.<BR>"); // Display the number of files uploaded 
out.println(count + " file(s) uploaded.");
%>
</BODY>
</HTML>

解决方案 »

  1.   

    to  baitianhai(hong) :
    是上传到数据库,不是文件夹下!
      

  2.   

    数据库的在这里
    http://www.jspsmart.com/scripts/showsource/showsource.asp?VPATH=/scripts/demo/jspSmartUpload/en/sample4.jsp主要是这个
    mySmartUpload.getFiles().getFile(0).fileToField(rs,"FILE");
      

  3.   

    to  baitianhai(hong):
    帮我看看以下代码,好吗?老是过不去!
    <%
        //项目ID
    String strProjID = request.getParameter("Proj_ID").trim();

    // Connect to the database
        Connection connOracle= getConn.getOraConnStr();  //获得数据库连接对象
    connOracle.setAutoCommit(false);

    // SQL Request
    PreparedStatement pstmtOracle=null;
    ResultSet rsOracle=null;
        String strInsertSql="";//Insert语句
        String strSelectSql="";//Select语句 // Initialization 
    mySmartUpload.initialize(pageContext);  
    mySmartUpload.upload();

    for(int i=0;i<mySmartUpload.getFiles().getCount();i++)
    {
      try 
     { 
    //添加空记录
                    strInsertSql="insert into T1302 values('"+strProjID+"',empty_blob(),'','"+(i+1)+"')";
    pstmtOracle=connOracle.prepareStatement(strInsertSql);
                    pstmtOracle.execute();
    pstmtOracle.clearParameters();

    //添加文件到BLOB字段
    strSelectSql="select * from T1302 where Project_ID='"+strProjID+"' and Contract_Order='"+(i+1)+"' for update";
                    pstmtOracle= connOracle.prepareStatement(strSelectSql,ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_UPDATABLE);
    rsOracle=pstmtOracle.executeQuery();

    // if the resultset is not null
    if (rsOracle.next())
    {  
    // upload file in the DB if this file is not missing 
    if (!mySmartUpload.getFiles().getFile(i).isMissing())
    {  
    try 
    {  
    rsOracle.updateString("File_Name",mySmartUpload.getFiles().getFile(i).getFileName()); 

    // Add the current file in the DB field 
    mySmartUpload.getFiles().getFile(i).fileToField(rsOracle,"Contract");  

    // Update 
    rsOracle.updateRow(); 
    }
    catch(Exception e) 

       out.println("An error occurs : " + e.toString());
    }
      }  
                }  
     
     //提交
     connOracle.commit();
      }
      catch(Exception e) 
     { 
      out.println("An error occurs : " + e.toString());
     }
    }//关闭数据库连接
    connOracle.close();  
    %>