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