首页 > 编程 > .NET > 正文

ASP.NET上传大文件控件

2024-07-10 13:09:12
字体:
来源:转载
供稿:网友

这段时间写了个asp.net 上传大文件控件。经过测试,在ie中可显示进度条。特此共享,望广大网友多提意见。

大文件上传控件(包含进度条)

使用说明如下:

     <summary>
     上传进度条控件
     </summary>
     <example>
     web.config 配置
     <?xml version="1.0"?>
    <configuration>
       <configsections>
          <!--上传节点-->
          <sectiongroup name="slickupload">
             <section name="uploadlocationprovider" type="common.slickupload.configuration.uploadlocationproviderhandler, common"/>
          </sectiongroup>
       </configsections>
       <system.web>
          <httpruntime maxrequestlength="2024000" executiontimeout="300"/>
          <httphandlers>
         <add verb="*" path="commontoolsashx.ashx" type="common.web.appcontrol.commontoolsashx, common" />
         <add verb="*" path="commontoolsashx_xml.ashx" type="common.web.appcontrol.commontoolsashx_xml, common" />
          </httphandlers>
          <!--上传modules-->
          <httpmodules>
         <add name="httpuploadmodule" type="common.slickupload.httpuploadmodule, common"/>
          </httpmodules>
       </system.web>
       <appsettings>
          <!--上传临时路径-->
          <add key="uploadpath" value="c:/tddownload/temp"/>
          <!--许可上传页面,多个页面用';'分开-->
          <add key="httpuploadmodulepagegoon" value="upload.aspx;"/>
       </appsettings>
    </configuration>

     aspx页面
       //顶部
       <%@ register assembly="common" namespace="common.web.appcontrol" tagprefix="cc1" %>
        //form内
        <asp:fileupload id="fileuploadfile" runat="server" />
        <asp:button id="btnupload" runat="server" onclick="button1_click" text="upload" />
        <asp:hyperlink id="hycancel" runat="server">cancel</asp:hyperlink>
        <cc1:webuploadprogressbar id="webuploadprogressbarcontrol" runat="server" uploadpath="c:/tddownload"></cc1:webuploadprogressbar>


     aspx对应的cs代码
            protected void page_load(object sender, eventargs e)
            {
                //绑定上传客户端javascript事件
                this.btnupload.onclientclick = this.webuploadprogressbarcontrol.getuploadclick_javascript;
                //绑定上传取消客户端javascript事件
                this.hycancel.navigateurl = "javascript:" + this.webuploadprogressbarcontrol.getuploadcancelclick_javascript;
            }
            protected void btnupload_click(object sender, eventargs e)
            {
                //上传文件
                this.webuploadprogressbarcontrol.saveuploadfiles();       
            }
     </example>
     <remarks>必须在iis站点下设置端口或虚拟目录方可测试通过,又问题请和[email protected]联系</remarks>

 有问题请和[email protected]联系, email:[email protected]

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表