日期:2014-05-18  浏览次数:20865 次

文件上传时出现如下错误,请问是什么原因?
代码:
<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.0   Transitional//EN ">
<HTML>
<HEAD>
<TITLE>   栏目添加   </TITLE>
<META   NAME= "Generator "   CONTENT= "EditPlus ">
<META   NAME= "Author "   CONTENT= " ">
<META   NAME= "Keywords "   CONTENT= " ">
<META   NAME= "Description "   CONTENT= " ">
</HEAD>
<%@page   contentType= "text/html;charset=GBK "%>
<%@page   language= "java "   import= "com.jspsmart.upload.* "%>
<%@page   import= "java.util.*,java.sql.*,java.text.*,java.sql.Date "%>
<jsp:useBean   id= "db "   class= "bean.ConnDB "   scope= "session "/>
<jsp:useBean   id= "mySmartUpload "   scope= "page "   class= "com.jspsmart.upload.SmartUpload "/>


<BODY>
<%
  request.setCharacterEncoding( "GBK ");
  SimpleDateFormat   formatter_f=new   SimpleDateFormat( "yyyy-MM-dd   HH:mm:ss ");
    java.util.Date   now=new   java.util.Date();

      mySmartUpload.initialize(pageContext);
      mySmartUpload.upload();

      com.jspsmart.upload.File   myFile=mySmartUpload.getFiles().getFile(0);
    String   GetNewID=formatter_f.format(now).substring(0,4)+formatter_f.format(now).substring(5,7)+formatter_f.format(now).substring(8,10)+formatter_f.format(now).substring(11,13)+formatter_f.format(now).substring(14,16)+formatter_f.format(now).substring(17)+myFile.getFileName();
        //如果文件存在,则保存
      if(!myFile.isMissing()){
          myFile.saveAs( "upload/ "+GetNewID);
      }
String   bt=mySmartUpload.getRequest().getParameter( "classname ");

try{
String   strUpd= "INSERT   INTO   SPecialS   (SName)   VALUES( ' "+bt+ " ', ' "+GetNewID+ " ') ";
db.executeUpdate(strUpd);
response.sendRedirect( "saveclass.jsp ");
db.close();
}
catch(Exception   e){System.err.print(e);}
%>
</BODY>
</HTML>

------解决方案--------------------
用APACHE的Commons FileUpload吧?那个JSPSmartUpload太麻烦,功能也不强大啊!