Thank you very much for brettle's Open Source
Supports. NET 1.1. NET 2.0
Here is the live demo
It is not easy to find out. It is really difficult to find an open source item under. net.
Of course, there are a lot of components for uploading large files, such as abcupload slickupload, but not open source. All of them are commercial code that brings more than N $, so...
Installation Method
: Http://www.brettle.com/neatupload#Download
1. Add brettle. Web. neatupload. DLL to the toolbox. You can see the inputfile and other controls in the toolbox.
2. Copy the folder neatupload to the root directory.
3. Drag and Drop the upload control inputfile and the progress bar progressbar to add the upload button. The code on the ASPX page is as follows:
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Upload: inputfile id = "attachfile" runat = "server"> </upload: inputfile>
<Asp: button id = "Upload" runat = "server" text = "Upload" onclientclick = "togglevisibility ('ssssbar', 'on')" onclick = "upload_click"/>
<Div id = "progressbar" style = "display: none;">
<Upload: progressbar id = "pbprogressbar" runat = "server" inline = "true" width = "500px" Height = "100"> </upload: progressbar>
</Div>
</Div>
</Form>
</Body>
4. Add the togglevisiblity function of the script code to the page as follows:
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function togglevisibility (ID, type)
{
El = Document. getelementbyid (ID );
If (El. Style)
{
If (type = 'on ')
{
El. style. Display = 'block ';
}
Else
{
El. style. Display = 'none ';
}
}
Else
{
If (type = 'on ')
{
El. Display = 'block ';
}
Else
{
El. Display = 'none ';
}
}
}
</SCRIPT>
5. Add the event upload_click to the Upload File button.
Protected void upload_click (Object sender, eventargs E)
{
String filename = This. attachfile. filename; // obtain the full path of the uploaded file
String extenname = system. Io. Path. getextension (filename); // get the extension
String savefilename = system. io. path. combine (request. physicalapplicationpath, datetime. now. tostring ("yyyymmddhhmm") + extenname); // merge the two paths to the full path uploaded to the server.
If (this. attachfile. contentlength> 0)
{
Try
{
This. attachfile. moveTo (savefilename, brettle. Web. neatupload. movetooptions. Overwrite );
}
Catch (exception ex)
{
Throw ex;
}
}
}
6. Add the HTTP module declaration in the configuration file web. config:
<Httpmodules usefullyqualifiedredirecturl = "true">
<Add name = "uploadhttpmodule" type = "brettle. Web. neatupload. uploadhttpmodule, brettle. Web. neatupload"/>
</Httpmodules>
7. You must make other settings in Web. config to ensure perfection.
Add in <configuration>
<Configsections>
<Sectiongroup name = "system. Web">
<Section name = "neatupload" type = "brettle. Web. neatupload. configsectionhandler, brettle. Web. neatupload" allowlocation = "true"/>
</Sectiongroup>
</Configsections>
Add
<Neatupload usehttpmodule = "false" maxnormalrequestlength = "4096" maxrequestlength = "2097151" defaultprovider = "filesystemuploadstorageprovider">
<Providers>
<Add name = "filesystemuploadstorageprovider"
Type = "brettle. Web. neatupload. filesystemuploadstorageprovider, brettle. Web. neatupload"/>
</Providers>
</Neatupload>
Add the following position in <configuration>
<Location Path = "default. aspx">
<System. Web>
<Neatupload usehttpmodule = "true"/>
<Httpruntime maxrequestlength = "2097151" executiontimeout = "3600" usefullyqualifiedredirecturl = "true"/>
</System. Web>
</Location>
</Configuration>