asp.net neatupload support large File Upload component _ Practical skills

Source: Internet
Author: User

1. Add Brettle.Web.NeatUpload.dll to the toolbox to see controls such as Inputfile appear in the toolbox.
2. Copy folder Neatupload to root directory.
3. Drag and drop use upload control Inputfile and progress bar ProgressBar, add upload file button. aspx page code is as follows:

Copy Code code as follows:

<body>
<form id= "Form1" runat= "Server" >
<div>
<upload:inputfile id= "Attachfile" runat= "Server" ></upload:InputFile>
<asp:button id= "Upload" runat= "text=" Upload "onclientclick=" togglevisibility (' ProgressBar ', ' on ') " onclick= "Upload_click"/>
<div id= "ProgressBar" style= "Display:none;" >
<upload:progressbar id= "Pbprogressbar" runat= "Server" inline= "true" width= "500px" height= "M" > </upload: Progressbar>
</div>
</div>
</form>
</body>

4. Add the script code togglevisiblity function to the page as follows:
Copy Code code 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 event Upload_click to the button that uploaded the file

Copy Code code as follows:

protected void Upload_click (object sender, EventArgs e)
{
String FileName = this. attachfile.filename;//get the full path to the uploaded file
String extenname = System.IO.Path.GetExtension (FileName);//Get extension
String savefilename = System.IO.Path.Combine (Request.physicalapplicationpath, DateTime.Now.ToString ("Yyyymmddhhmm" + extenname);//merge two paths for full path to upload to 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 to the configuration file Web.config:
Copy Code code as follows:

<add name= "Uploadhttpmodule" type= "Brettle.Web.NeatUpload.UploadHttpModule, Brettle.Web.NeatUpload"/>


7. Some other settings need to be made in web.config to ensure perfection.
Join in <configuration>
Copy Code code as follows:

<configSections>
<sectiongroup name= "System.Web" >
<section name= "Neatupload" type= "Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" Allowlocation= "true"/>
</sectionGroup>
</configSections>

Join in <system.web>
Copy Code code as follows:

<neatupload usehttpmodule= "false" maxnormalrequestlength= "4096" maxrequestlength= "2097151" defaultProvider= " Filesystemuploadstorageprovider ">
<providers>
<add name= "Filesystemuploadstorageprovider" type= "Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload "/>
</providers>
</neatUpload>

Join at the back of the <configuration>
Copy Code code as follows:

<location path= "default.aspx" >
<system.web>
<neatupload usehttpmodule= "true"/>
</system.web>
</location>
</configuration>

Address download, which has a detailed use of the document

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.