请教高手看这段程序,一次点击自动两次上传相同图片,这个代码哪里有问题啊?
yasoo 2005-05-28 02:08:18 //响应上传图片文件事件
public void picup_Click(object s1,EventArgs e1)
{
//选择了一个文件
if(FileUp.PostedFile.ContentLength != 0)
{
//验证上传类型
if(FileUp.PostedFile.ContentType == "image/jpeg" || FileUp.PostedFile.ContentType == "image/gif" || FileUp.PostedFile.ContentType == "image/bmp" || FileUp.PostedFile.ContentType == "image/jpg")
{
//取得文件名
string filename = FileUp.PostedFile.FileName;
//取得文件名长度
int i = filename.Length;
filename = filename.Remove(0,i-4);
string s = DateTime.Now.Year.ToString()
+DateTime.Now.Month.ToString()
+DateTime.Now.Day.ToString()
+DateTime.Now.Hour.ToString()
+DateTime.Now.Minute.ToString()
+DateTime.Now.Second.ToString()
+DateTime.Now.Millisecond.ToString();
string d=Server.MapPath("upfiles/") + s + filename;
//把每一个文件名保存在一个字符串里面.
//f = "";
//f = "upfiles/" + f + s + filename ;
//f = "upfiles/" + s + filename ;
//把f的值保存在ViewState里.
ViewState["filename"] += f;
//ViewState["filename"] =ViewState["filename"] + f;**/
FileUp.PostedFile.SaveAs(d);
message.Text = "上传成功";
Session["pic"] = "1";
}
else
{
message.Text = "只能上传jpeg,jpg,gif,bmp格式图片";
Session["pic"] = "0";
}
}
else
{
message.Text="请选择上传文件";
Session["pic"] = "0";
}
}