protected void upload_Click(object sender, EventArgs e)
{
string text = this.Session["port"].ToString();
string path = "~/Room_JS/" + text + "/tp/gb/";
bool flag = false;
string str = base.Server.MapPath(path);
if (this.FileUpload1.HasFile)
{
string a = Path.GetExtension(this.FileUpload1.FileName).ToLower();
string[] array = new string[]
{
".gif"
};
for (int i = 0; i < array.Length; i++)
{
if (a == array[i])
{
flag = true;
}
}
}
if (this.FileUpload1.PostedFile.ContentLength > 3000000)
{
flag = false;
base.Response.Write("<script>alert('文件不能超过3MB');window.location.href='Jsedit_jbshzh_edit.aspx?port=" + text + "';</script>");
}
if (flag)
{
try
{
string fileName = this.FileUpload1.PostedFile.FileName;
FileInfo fileInfo = new FileInfo(fileName);
string text2 = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + ".gif";
this.FileUpload1.SaveAs(str + text2);
string str2 = text2.Replace(".gif", "");
string text3 = "gb/" + str2;
base.Response.Write("<script>alert('图片上传成功,请点击保存修改');</script>");
this.label1.Text = "文件上传成功";
this.label2.Text = string.Concat(new object[]
{
"<b><font color='red' size ='4'>图标路径</font>:</b>http://",
base.Request.Url.Host,
"/room_js/",
text,
"/tp/gb/",
text2,
"<br /><b>文件大小:</b>",
this.FileUpload1.PostedFile.ContentLength,
"字节<br /><b>文件类型:</b>",
this.FileUpload1.PostedFile.ContentType,
"<br />"
});
this.TextBox3.Text = text3;
}
catch (Exception var_12_26C)
{
this.label1.Text = "文件上传不成功.";
}
}
else
{
this.label1.Text = "只能够上传.gif文件.";
}
}