1.在工具箱中添加Brettle.Web.NeatUpload.dll,可以看到工具箱中出现InputFile等控件。
2.复制文件夹NeatUpload到根目录.
3.拖放使用上传控件InputFile和进度条ProgressBar,添加上传文件的按钮.aspx页面代码如下:

Brettle.Web.NeatUpload.dll支持的大文件上传_ide<body>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide  
<form id="form1" runat="server">
Brettle.Web.NeatUpload.dll支持的大文件上传_ide  
<div>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide       
<upload:InputFile id="AttachFile" runat="server"></upload:InputFile>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide      
<asp:Button ID="Upload" runat="server" Text="Upload"  OnClientClick="ToggleVisibility('ProgressBar','on')" OnClick="Upload_Click"/>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide        
<div id="ProgressBar"  style="display:none;">
                   <upload:progressbar id="pbProgressBar" runat="server" Inline="true" Width="500px" Height="100"> </upload:progressbar>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide      
</div>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide 
</div>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide 
</form>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
</body>

4.添加脚本代码ToggleVisiblity函数到页面上如下:

Brettle.Web.NeatUpload.dll支持的大文件上传_ide<script type="text/javascript" language="javascript">
Brettle.Web.NeatUpload.dll支持的大文件上传_ide       
function ToggleVisibility(id, type) 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide       {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide         el 
= document.getElementById(id);
Brettle.Web.NeatUpload.dll支持的大文件上传_ide         
if(el.style)
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide               
if(type == 'on')
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
                {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                    
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                    el.style.display 
= 'block';
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
                } 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                
else 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                   
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                    el.style.display 
= 'none';
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
                }
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            } 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            
else 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide               
if(type == 'on')
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
               {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                     
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                    el.display 
= 'block';
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
               } 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide               
else 
Brettle.Web.NeatUpload.dll支持的大文件上传_ide               {
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                   
Brettle.Web.NeatUpload.dll支持的大文件上传_ide                    el.display 
= 'none';
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
               }
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            }
Brettle.Web.NeatUpload.dll支持的大文件上传_ide       }
Brettle.Web.NeatUpload.dll支持的大文件上传_ide 
</script>

5.给上传文件的按钮添加事件Upload_Click

Brettle.Web.NeatUpload.dll支持的大文件上传_ide protected void Upload_Click(object sender, EventArgs e)
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_44Brettle.Web.NeatUpload.dll支持的大文件上传_控件_45    
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_46{
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47        
string FileName = this.AttachFile.FileName;//获取上传文件的全路径
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47
        string ExtenName = System.IO.Path.GetExtension(FileName);//获取扩展名
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47
        string SaveFileName = System.IO.Path.Combine(Request.PhysicalApplicationPath, DateTime.Now.ToString("yyyyMMddhhmm"+ ExtenName);//合并两个路径为上传到服务器上的全路径
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47
          if (this.AttachFile.ContentLength > 0)
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_51Brettle.Web.NeatUpload.dll支持的大文件上传_ide_52        
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_46{
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47            
try
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_51Brettle.Web.NeatUpload.dll支持的大文件上传_ide_52            
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_46{
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47                            
this.AttachFile.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_59                    }

Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47            
catch (Exception ex)
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_51Brettle.Web.NeatUpload.dll支持的大文件上传_ide_52            
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_46{
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47                            
throw ex;
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_59                    }
Brettle.Web.NeatUpload.dll支持的大文件上传_ide_47
Brettle.Web.NeatUpload.dll支持的大文件上传_控件_59                }

Brettle.Web.NeatUpload.dll支持的大文件上传_ide_68        }

6.在配置文件web.config中添加http模块声明:

Brettle.Web.NeatUpload.dll支持的大文件上传_ide <httpModules useFullyQualifiedRedirectUrl="true">
Brettle.Web.NeatUpload.dll支持的大文件上传_ide      
<add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule, Brettle.Web.NeatUpload" />
Brettle.Web.NeatUpload.dll支持的大文件上传_ide 
</httpModules>

7.需要在web.config进行其他一些设置才能保证完美
在<configuration>里面加入

Brettle.Web.NeatUpload.dll支持的大文件上传_ide<configSections>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide        
<sectionGroup name="system.web">
Brettle.Web.NeatUpload.dll支持的大文件上传_ide          
<section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" allowLocation="true" />
Brettle.Web.NeatUpload.dll支持的大文件上传_ide        
</sectionGroup>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide      
</configSections>

在 <system.web>加入

Brettle.Web.NeatUpload.dll支持的大文件上传_ide<neatUpload useHttpModule="false" maxNormalRequestLength="4096" maxRequestLength="2097151" defaultProvider="FilesystemUploadStorageProvider">
Brettle.Web.NeatUpload.dll支持的大文件上传_ide          
<providers>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide            
<add name="FilesystemUploadStorageProvider"
Brettle.Web.NeatUpload.dll支持的大文件上传_ide         type
="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload" />
Brettle.Web.NeatUpload.dll支持的大文件上传_ide          
</providers>
    </neatUpload>

在<configuration>里面的后面位置加入

Brettle.Web.NeatUpload.dll支持的大文件上传_ide<location path="Default.aspx" >
Brettle.Web.NeatUpload.dll支持的大文件上传_ide        
<system.web>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide          
<neatUpload useHttpModule="true" />
Brettle.Web.NeatUpload.dll支持的大文件上传_ide          
<httpRuntime maxRequestLength="2097151" executionTimeout="3600" useFullyQualifiedRedirectUrl="true" />
Brettle.Web.NeatUpload.dll支持的大文件上传_ide        
</system.web>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide      
</location>
Brettle.Web.NeatUpload.dll支持的大文件上传_ide
</configuration>

最后这里是上面需要的文件和dll文件的源代码以及怎样用的例子

 

.Net 技术探讨群 4151320

欢迎大家加入!!!