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", "<script language='javascript' defer>alert('档案文件太大');</script>");
return;
}
else
{
if (new olecado().upfile(xx, addfilename, uptime))
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("file/") + addfilename);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('文件已上传');</script>");
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('文件上传失败');</script>");
}
}
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('请选择文件后上传,详情咨询5227101!');</script>");
return;
}
}
else
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('请选择单位后上传文件,详情咨询5227101!');</script>");
return;
}
}