乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      上傳按鈕單擊事件示例

       悟靜 2011-12-14

       protected void BtnSubmit_Click(object sender, EventArgs e)
          {
              {
                  try
                  {
                      MyConn = DB.CreateDB();

                      string title =FunStr(this.TxtTitle.Text);//轉(zhuǎn)換
                      string content =FunStr(this.TxtContent.Text);
                      string ptype = Request.QueryString["action"].ToString();
                      string FileName = myFile.Value;
                      HttpPostedFile UpFile = myFile.PostedFile; //獲取對由客戶端指定的上傳文件的訪問
                      FileLength = UpFile.ContentLength;//獲取上傳文件的字節(jié)大小
                      if (FileLength == 0)
                      {
                          MyConn.Open();
                          OleDbCommand cmd1 = new OleDbCommand("insert into product(pro_name,title,content) values('" + ptype + "','" + title + "','" + content + "')",MyConn);
                          cmd1.ExecuteNonQuery();
                          Response.Write("<script>alert('數(shù)據(jù)添加成功');window.location.href='Admin_Add.aspx?action=" + ptype + "'</script>");
                          MyConn.Close();
                      }
                      else
                      {
                          string exName = FileName.Substring(FileName.LastIndexOf(".") + 1).ToUpper();//截取圖片的后綴名,改名
                          if (exName == "JPG" || exName == "BMP" || exName == "GIF")//判斷圖片的類型
                          {
                              if (FileLength > 1024000)//判斷圖片是否大于200k(根據(jù)自己的需要判斷大?。?BR>                        {
                                  Response.Write("<script>alert('對不起,圖片大小不能大于1M');window.location.href='Admin_Add.aspx?action=" + ptype + "'</script>");
                                  return;
                              }
                              else
                              {
                                  string ImageName = DateTime.Now.ToString("yyyyMMddhhmmssfff") + "." + exName;//圖片名稱設(shè)置為保存的時(shí)間
                                  Byte[] FileByte = new Byte[FileLength]; //圖象文件儲(chǔ)存到數(shù)組 
                                  Stream ObjectStream = UpFile.InputStream;//建立數(shù)據(jù)流對像,獲取一個(gè) Stream 對象,該對象指向一個(gè)上載文件,以準(zhǔn)備讀取該文件的內(nèi)容。

                                  ObjectStream.Read(FileByte, 0, FileLength); //讀取圖象文件數(shù)據(jù)
                                  string StrSql = "Insert Into product(pro_name,img,title,content) Values('" + ptype + "',@ImageName,'" + title + "','" + content + "')";
                                  OleDbCommand Cmd = new OleDbCommand(StrSql, MyConn);
                                  //Cmd.Parameters.Add("@Image",OleDbType.Binary, FileLength).Value = FileByte;
                                  Cmd.Parameters.Add("@ImageName", OleDbType.VarChar, 100).Value = ImageName;
                                  MyConn.Open();
                                  this.myFile.PostedFile.SaveAs(Server.MapPath("/upload") + "\\" + ImageName);
                                  Cmd.ExecuteNonQuery();
                                  MyConn.Close();
                                  Response.Write("<script>alert('數(shù)據(jù)添加成功');window.location.href='Admin_Add.aspx?action="+ptype+"'</script>");
                              }
                          }
                          else
                          {
                              Response.Write("<script>alert('對不起,請選擇正確的的圖片!');window.location.href='Admin_Add.aspx?action=" + ptype + "'</script>");
                              return;
                          }
                      }
                     

                  }
                  catch (Exception ex)
                  {
                      Response.Write("<script>alert('" + ex.Message + "')</script>");
                  }
              }

          }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多