上传文件asp.net c#

2021-01-14 11:20

阅读:516

标签:cte   asp   turn   message   str   opd   net   star   选择   

protected void Button1_Click(object sender, EventArgs e)
{

if (this.DropDownList1.SelectedIndex > 0)
{
string xx = this.DropDownList1.SelectedValue.Trim();
string uptime = DateTime.Now.ToShortDateString().ToLower().ToString();
if (FileUpload1.PostedFile.ContentLength > 0)
{
string addfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(".")).ToLower();
if (FileUpload1.PostedFile.ContentLength > 20000000)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "");
return;
}
else
{
if (new olecado().upfile(xx, addfilename, uptime))
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("file/") + addfilename);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "");
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "");
}
}
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "");
return;
}

}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "");
return;
}


}

上传文件asp.net c#

标签:cte   asp   turn   message   str   opd   net   star   选择   

原文地址:https://www.cnblogs.com/houweidong/p/12263242.html


评论


亲,登录后才可以留言!