zoukankan      html  css  js  c++  java
  • 一个大文件上传组件RadUpLoad(带进度条时间显示)

    private string SaveFile()
       {
           string _return = "";
           foreach (UploadedFile file in RadUploadContext.Current.UploadedFiles)
           {
     
               string Path = Server.MapPath(@"/upload/media");
     
               //如果路径不存在,则创建
               if (System.IO.Directory.Exists(Path) == false
               {
                   System.IO.Directory.CreateDirectory(Path);
               }
     
               //组合路径,file.GetName()取得文件名
               Path = Path + "/" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + "." + file.GetExtension();
     
               //保存
               file.SaveAs(Path, true);
               _return = Path;
           }
           return _return;
       }
     此处代码要在上面增加
    using Telerik.WebControls;
     
     
     
    前台代码:
    顶部注册组件
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.QuickStart" Assembly="Telerik.QuickStart" %>
    <%@ Register TagPrefix="radU" Namespace="Telerik.WebControls" Assembly="RadUpload.Net2" %>
    页面HTML
    <radU:RadProgressManager ID="Radprogressmanager1" Width="100%" runat="server"/>
    <radU:RadProgressArea ID="progressArea1" Width="100%" runat="server">
    </radU:RadProgressArea>
    <asp:FileUpload ID="FileUpload1" Width="180" runat="server"/>
    引用DLL为RadUpload.Net2.dll与 Telerik.QuickStart.dll ,RadUpload.Net2.xml都在BIN目录下

    webconfig配置

     
       <httpModules>
      
          <add name="RadUploadModule" type="Telerik.WebControls.RadUploadHttpModule, RadUpload.Net2"/>
        </httpModules>
     <httpHandlers>
     <add verb="*" path="Telerik.RadUploadProgressHandler.aspx" type="Telerik.WebControls.RadUploadProgressHandler, RadUpload.Net2"></add>
      </httpHandlers>
    <!--此处必须有要httpRuntime配置,否则报DNSerror,而不能上传-->
    <httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>

    Bin文件下载:下载文件

  • 相关阅读:
    题解 [BZOJ1295][SCOI2009] 最长距离
    题解 [51nod1274] 最长递增路径
    #leetcode刷题之路21-合并两个有序链表
    #leetcode刷题之路20-有效的括号
    #leetcode刷题之路19-删除链表的倒数第N个节点
    #leetcode刷题之路18-四数之和
    #leetcode刷题之路17-电话号码的字母组合
    #leetcode刷题之路16-最接近的三数之和
    #leetcode刷题之路15-三数之和
    #leetcode刷题之路14-最长公共前缀
  • 原文地址:https://www.cnblogs.com/12go/p/2284558.html
Copyright © 2011-2022 走看看