本文介绍了如何使用AjaxFileUpload控件将文件上载到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的朋友们, 如果您解决以下问题,您将非常感谢。解决方案 使用 System.Web.Security; 使用 System.Web.UI; 使用 System.Web.UI.HtmlControls; 使用 System.Web.UI.WebControls; 使用 System.Web.UI.WebControls.WebParts; 使用 System.Xml.Linq; 使用 System.IO; 使用 BU_AppCode; 使用 System.Data.SqlClient; public partial class PopUp :System.Web.UI.Page { protected void Page_Load( object sender,EventArgs e){} protected void btnSave_Click( object sender,EventArgs e) { string SavePath2 = Server.MapPath( 〜/ BU_Web1 / UploadedFile / Einwilligung /); string fileNameList = ; if (fp_Makler.HasFile) { string SavePath1 = Server.MapPath( 〜/ BU_Web1 / UploadedFile / Maklerauftrag /); lb_Message.Text = ; string FileName1 = Path.GetFileNameWithoutExtension(fp_Makler.FileName); string FileExtension1 = Path.GetExtension(fp_Makler.FileName); float FileSize1 = fp_Makler.PostedFile.ContentLength; FileSize1 = FileSize1 / 1024 ; string uniqueName1 = YourFileName; SavePath1 = SavePath1 + uniqueName1 + FileExtension1; if (FileSize1 < 15360 ) // && FileSize2< 15360)//如果文件大小小于15 MB,则将其限制 { fp_Makler.SaveAs(SavePath1); fileNameList + = , + uniqueName1 + FileExtension1; } else { lb_Message.Text = FileName1 + FileExtension1 + Datei istzugroß; } } if (fileNameList!= ) { SqlCommand cmd = new SqlCommand(); cmd.CommandText = SP_Fr_FileUpDate; SqlParameterCollection paramColl = cmd.Parameters; paramColl.AddWithValue( @ fileNameList,fileNameList.Substring( 1 )); paramColl.AddWithValue( @ Kundennummer,Request.QueryString [ Kundennummer]); 尝试 { BU_UtilDB.ExecuteProcedure(cmd); } catch (例外情况) { } Page.RegisterStartupScript( , < script type ='text / javascript'> window.opener.location.href ='StatusBU.aspx'; window.close()< / script>); } else { lb_Message.Text = Es wurde keine Datei zum上传ausgewählt; } } } Dear Friends,You will be very much thankful if you solve the below problem. 解决方案using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;using System.IO;using BU_AppCode;using System.Data.SqlClient;public partial class PopUp : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void btnSave_Click(object sender, EventArgs e) { string SavePath2 = Server.MapPath("~/BU_Web1/UploadedFile/Einwilligung/"); string fileNameList = ""; if (fp_Makler.HasFile) { string SavePath1 = Server.MapPath("~/BU_Web1/UploadedFile/Maklerauftrag/"); lb_Message.Text = ""; string FileName1 = Path.GetFileNameWithoutExtension(fp_Makler.FileName); string FileExtension1 = Path.GetExtension(fp_Makler.FileName); float FileSize1 = fp_Makler.PostedFile.ContentLength; FileSize1 = FileSize1 / 1024; string uniqueName1 = "YourFileName"; SavePath1 = SavePath1 + uniqueName1 + FileExtension1; if (FileSize1 < 15360) //&& FileSize2 < 15360) //If file size less than 15 MB, Then contine it { fp_Makler.SaveAs(SavePath1); fileNameList += "," + uniqueName1 + FileExtension1; } else { lb_Message.Text = FileName1 + FileExtension1 + " Datei ist zu groß"; } } if (fileNameList != "") { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SP_Fr_FileUpDate"; SqlParameterCollection paramColl = cmd.Parameters; paramColl.AddWithValue("@fileNameList", fileNameList.Substring(1)); paramColl.AddWithValue("@Kundennummer", Request.QueryString["Kundennummer"]); try { BU_UtilDB.ExecuteProcedure(cmd); } catch (Exception ex) { } Page.RegisterStartupScript("", "<script type='text/javascript'>window.opener.location.href='StatusBU.aspx';window.close()</script>"); } else { lb_Message.Text = "Es wurde keine Datei zum Upload ausgewählt"; }}} 这篇关于如何使用AjaxFileUpload控件将文件上载到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!