不用设
用个文件类型提交上来就行了
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0057)http://localhost:8080/jspsmartfile/jsp/uploadTemplate.jsp -->
<HTML><HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY bgColor=#e6e6e6><BR>
<FORM action="upload.jsp"  encType=multipart/form-data method=post>
<TABLE>
  <TBODY>
  <TR>
    <TD><FONT color=#000000 face=helv,helvetica size=1>&nbsp;&nbsp;File  
      :&nbsp;</FONT>&nbsp;&nbsp;<INPUT  size=60 type=file  name="file"></TD></TR>
        <TR>
    <TR>
    <TD><FONT color=#000000 face=helv,helvetica size=1>&nbsp;&nbsp;File  
      :&nbsp;</FONT>&nbsp;&nbsp;<INPUT  size=60 type=file  name="file1"></TD></TR>
        <TR>
    <TD><FONT color=#000000 face=helv,helvetica size=1>&nbsp;&nbsp;File  
      :&nbsp;</FONT>&nbsp;&nbsp;<INPUT  size=60 type=text  name="text"></TD></TR>
  <TR>
    <TD 
align=right><INPUT type=submit value=Send name="send"></TD></TR></TBODY></TABLE></FORM></BODY></HTML>

解决方案 »

  1.   

    <%@ page contentType="text/html; charset=GBK" %>
    <jsp:useBean id="mySmartUpload" scope="page" class="com.jspsmart.upload.SmartUpload" />
    <%
    // Variables
    int count=0;
    String fileName="";//文件名
    String fileExt="";//扩展名// Initialization
    mySmartUpload.initialize(pageContext);
    //com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
    // Only allow txt or htm files
    //mySmartUpload.setAllowedFilesList("htm,html,txt");// DeniedFilesList can also be used :
    mySmartUpload.setDeniedFilesList("exe,bat,jsp");// Deny physical path
    // mySmartUpload.setDenyPhysicalPath(true);// Only allow files smaller than 50000 bytes
    // mySmartUpload.setMaxFileSize(50000);// Deny upload if the total fila size is greater than 200000 bytes
    // mySmartUpload.setTotalMaxFileSize(200000);// Upload
    mySmartUpload.upload();com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
    if (!myFile.isMissing()) {
      fileName = myFile.getFileName();
      fileExt = myFile.getFileExt();
      myFile.saveAs("/upload/"+fileName,mySmartUpload.SAVE_VIRTUAL);
    }// Display the number of files uploaded
    out.println(mySmartUpload.getFiles().getCount() + " file(s) uploaded.");//out.println(myUtil.getSystime());
    %>