ASP. net2.0 uploads large file third-party control radupload

Source: Internet
Author: User
1. Add <system. Web> in Web. config:
<Httphandlers>
<Add verb = "*" Path = "telerik. raduploadprogresshandler. aspx" type = "telerik. webcontrols. raduploadprogresshandler, radupload. net2"/>
</Httphandlers>
<Httpmodules>
<Add name = "raduploadmodule" type = "telerik. webcontrols. raduploadhttpmodule, radupload. net2"/>
</Httpmodules>

2. Reference and declare use

Page:

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>

<% @ Register Assembly = "radupload. net2" namespace = "telerik. webcontrols" tagprefix = "Radu" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Radu: radprogressmanager id = "radprogressmanager1" runat = "server"/>
& Nbsp; <br/>
<Input id = "file1" runat = "server" class = "uploadbox" name = "file1" type = "file"/> <br/>
<Radu: radprogressarea id = "radprogressarea1" runat = "server">
</Radu: radprogressarea>
<Br/>
<Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"/> </div>
</Form>
</Body>
</Html>

 

RearCode:

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using telerik. webcontrols;

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{

}
Protected void button#click (Object sender, eventargs E)
{

// Generate guid
Guid id = system. guid. newguid ();

Foreach (uploadedfile up in raduploadcontext. Current. uploadedfiles)
{
String filename = up. getname ();
Int Index = filename. lastindexof (".");
String type = filename. substring (INDEX );

Up. saveas (server. mappath ("~ /Upload ") +" \ "+ id. tostring () + type, true );
}
}
}

 

3. File Size Control. If it is too large, a page error is reported.
Add in Web. config

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.