Asp. Net Upload Component RadUpLoad (with progress bar time displayed)

Source: Internet
Author: User

During the development of my enterprise management system, the biggest problem encountered was the upload of large files. To upload large files in asp or php, you need to use components (this is restricted by the VM ). However, it seems much easier to upload large files in asp.net. The following provides the asp.net large file upload solution.
Paste the code and do. net development. What do you mean at first glance?

1. btnSave save file submit button event

[Html]
/// <Summary>
/// BtnSave save file submit button event
/// </Summary>
/// <Param name = "sender"> </param>
/// <Param name = "e"> </param>
Protected void btnSave_Click (object sender, EventArgs e)
{
Foreach (UploadedFile file in RadUploadContext. Current. UploadedFiles)
{
String Path = Server. MapPath (@ "Uploads ");
// If the path does not exist, create
If (System. IO. Directory. Exists (Path) = false)
{
System. IO. Directory. CreateDirectory (Path );
}
// Combined path, file. GetName () to get the file name
Path = Path + "/" + file. GetName (). ToString ();
// Save
File. SaveAs (Path, true );
}
}

Add using Telerik. WebControls to the code above;
 
2. register the component at the top of the front-end code
[Html]
<% @ Register TagPrefix = "telerik" Namespace = "Telerik. QuickStart" Assembly = "Telerik. QuickStart" %>
<% @ Register TagPrefix = "radU" Namespace = "Telerik. WebControls" Assembly = "RadUpload. Net2" %

3. Html page
[Html]
<Radu: radprogressmanager id = "Radprogressmanager1" Width = "100%" runat = "server" Height = "37px"/>
<Radu: radprogressarea id = "progressArea1" Width = "100%" runat = "server"> </radu: radprogressarea>

<Asp: FileUpload ID = "FileUpload1" runat = "server"/>
<Asp: Button ID = "btnSave" runat = "server" Text = "Button" OnClick = "btnSave_Click"/>

4. The reference DLL is RadUpload. Net2.dll and Telerik. QuickStart. dll. RadUpload. Net2.xml are all in the BIN directory.
5. webconfig Configuration
[Html]
<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 must be configured here; otherwise, DNSerror is reported, but not uploaded. -->
 
<HttpRuntime maxRequestLength = "2097151" executionTimeout = "3600"/>

From my independent blog 90 boys share network, DEMO: http://www.bkjia.com/uploadfile/2012/0607/20120607110901476.zip
 

 


From Share Network-shi's blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.