图片上传?
恰巧有一个 刚做完 protected void Button1_Click(object sender, EventArgs e)
    {
         bool fileOK = false;
        //获取基于应用程序根文件夹的绝对路径
        string path = Server.MapPath("~/uploadfiles/");
        //如果确认了上传文件,则判断文件的类型是否符合要求
        if (FileUpload1.HasFile)//如果有文件
        {
            string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            string[] allowedExtensions ={ ".gif", ".png", ".bmp", ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOK = true;
                }
            }
        }
        if (fileOK)
        {
            try
            {
                string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()+FileUpload1.FileName.ToString();
                FileUpload1.SaveAs(path + name);
                labMsg1.Text = "上传成功!";
                string insertStr = "INSERT INTO Pictures ( [PicAbout] ,[PicName] ) VALUES ('"+this.TextBox1.Text.ToString()+"','"+name+"')";
                SqlConnection myCon = DB.createConnection();
                SqlCommand myCom = new SqlCommand(insertStr,myCon);
                myCon.Open();
                myCom.ExecuteNonQuery();
                myCon.Close();
                this.TextBox1.Text ="";
            }
            catch 
            {
                labMsg1.Text = "上传不成功!";
            }
        }又问题联系我!