1、wedconfig要插入的代码:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1 <configSections>
2 <sectionGroup name="system.web">
3 <section name="neatUpload" type="Brettle.Web.NeatUpload.ConfigSectionHandler, Brettle.Web.NeatUpload" allowLocation="true"/>
4 </sectionGroup>
5 </configSections>
6 <httpModules>
7 <system.wed
8 <add name="UploadHttpModule" type="Brettle.Web.NeatUpload.UploadHttpModule, Brettle.Web.NeatUpload"/>
9 </httpModules>
10 <neatUpload useHttpModule="true" maxNormalRequestLength="4096" maxRequestLength="2097151" defaultProvider="FilesystemUploadStorageProvider">
11 <providers>
12 <add name="FilesystemUploadStorageProvider" type="Brettle.Web.NeatUpload.FilesystemUploadStorageProvider, Brettle.Web.NeatUpload"/>
13 </providers>
14 </neatUpload>
15 </system.web
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<Upload:InputFile ID="AttachFile" runat="server" onpropertychange="loadimg()" Width="150px" />
<div id="ProgressBar" style="display:none; height: 21px;">
<upload:progressbar id="pbProgressBar" runat="server" Inline="true" Triggers="btnUpload" Width="584px"> </upload:progressbar>
</div>
<asp:Button ID="btnUpload" runat="server" Text="上传" OnClick="btnUpload_Click" />
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
if(AttachFile.HasFile)
string FileName = this.AttachFile.FileName;//获取上传文件的文件名,包括后缀
string ExtenName = System.IO.Path.GetExtension(FileName);//获取扩展名
if (ExtenName.ToLower() == ".jpg" || ExtenName.ToLower() == ".png" || ExtenName.ToLower() == ".gif")
{
string SaveName = DateTime.Now.ToString("yyyyMMddhhmmss") + ExtenName;
string SaveFileName = System.IO.Path.Combine(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, "Images\\" + SaveName);//合并两个路径为上传到服务器上的全路径
AttachFile.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
string url = "Images/" + SaveName; //文件保存的路径
float FileSize = (float)System.Math.Round((float)AttachFile.ContentLength / 1024000, 1); //获取文件大小并保留小数点后一位,单位是M
}
}
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function WebForm_OnSubmit()//主要点就在这里重写NeatUpload生成的WebForm_OnSubmit
{
var imgName = $("#txtImgName").val();
var tdate = $("#txtDate").val();
var path = $("#AttachFile").val();
if(imgName == ""){
alert("图片名称不能为空!");
return false;
}else if(tdate ==""){
alert("上传时间不能为空!");
return false;
}else if(path == ""){
alert("上传文件不能为空!");
return false;
}else if(!isExUpload){
loadimg();
}
else{
$("#btnUpload").arrt("disabled",true);
$("#ProgressBar").css("display","block");
NeatUpload_OnSubmitForm_form1(); //这一条代码和下一条一定要,这里的form1就是你formr的ID
return true;
}