jspSmartUpload实现上传现在

今天用这个东西试验了一下,挺好使,但是有一点挺让人郁闷,不知道什么原因,我起了一个文件名叫upload.html的文件,结果提交总是失败,换个名就好使了,I cannt understand,WHY!

代码贴出来

 

<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
< html >
    
< head >
        
< title > 文件上传 </ title >
        
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
    
</ head >
    
< body >
        
< align ="center" >
            上传文件选择
        
</ p >
        
< FORM  METHOD ="POST"  ACTION ="upload.jsp"  ENCTYPE ="multipart/form-data" >
            
< input  type ="hidden"  name ="TEST"  value ="good" >
            
< table  width ="75%"  border ="1"  align ="center" >
                
< tr >
                    
< td >
                        
< div  align ="center" >
                            1、
                            
< input  type ="FILE"  name ="FILE1"  size ="30" >
                        
</ div >
                    
</ td >
                
</ tr >
                
< tr >
                    
< td >
                        
< div  align ="center" >
                            
< input  type ="submit"  name ="Submit"  value ="上传它!" >
                        
</ div >
                    
</ td >
                
</ tr >
            
</ table >
        
</ FORM >
    
</ body >
</ html >

 

 upload.jsp代码

<% @ page contentType="text/html; charset=gb2312" language="java"
    import
="java.util.*,com.jspsmart.upload.*,java.lang.*" errorPage=""
%>
< html >
    
< head >
        
< title > 上传文件 </ title >
        
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
    
</ head >
    
< body >
        
< center >
            正在上传文件......
            
< br >
            
<%
                    try {
                    SmartUpload su 
= new SmartUpload();
                    su.initialize(pageContext);
                    
// 设定上传限制

                    
// 1.限制每个上传文件的最大长度。

                    su.setMaxFileSize(
10000);

                    
// 2.限制总上传数据的长度。

                    su.setTotalMaxFileSize(
20000);

                    
// 3.设定允许上传的文件(通过扩展名限制),仅允许doc,txt文件。

                    su.setAllowedFilesList(
"doc,txt");

                    
// 4.设定禁止上传的文件(通过扩展名限制),禁止上传带有exe,bat,jsp,htm,html扩展名的文件和没有扩展名的文件。

                    su.setDeniedFilesList(
"exe,bat,jsp,htm,html,,");

                    
// 上传文件

                    su.upload();
                    
int cnt = su.save("new/upfile/");
                    out.println(
"<br>" + cnt + "个文件上传成功!");
                } catch (java.lang.SecurityException ex) {
                    ex.printStackTrace();
                    out
                    .println(
"<br>文件上出错误,可能上传非法文件(禁止上传带有exe,bat,jsp,htm,html)<br>");
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            
%>
            
< href =up2.html >< div >
                    重新上传!
                
</ div >
    
</ body >
</ html >

你可能感兴趣的:(jspSmartUpload实现上传现在)