這段時間寫了個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]
新聞熱點
疑難解答
圖片精選