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文件下载:下载文件

posted on 2011-12-12 11:17  易尔购  阅读(3686)  评论(2编辑  收藏  举报