title: how i to re check only image in upload
body: <p>//  why this code no function if me upload 1.chicken.jpg 180kb 2.chicken.pdf but chicken.pdf follow insert to database </p>
  
  <pre><code>HttpFileCollection hfc = Request.Files;
                  if (hfc != null)
                  {
                      string cekDir = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["docLoc"], id_hazard_report);
  
                      string PicDir;
                      if (Directory.Exists(cekDir)) //check Folder avlalible or not
                      {
                          PicDir = cekDir;
                      }
                      else
                      {
                          DirectoryInfo di = Directory.CreateDirectory(cekDir); // create Folder
                          PicDir = cekDir;
                      }
  
                      string fullname;
                      string filename;            
                      FileUpload FileUpload1 = (FileUpload)FormView1.FindControl("FileUpload1");
                      string fileExt = Path.GetExtension(FileUpload1.FileName); //Get The File Extension 
  
  
                      for (int i = 0; i &lt; hfc.Count; i++)
                      {
                          HttpPostedFile hpf = hfc[i];
  
                          if (hpf.ContentLength &gt;0) 
                          {
                              ///full path name to check exist or not
                              fullname = string.Format("{0}\\{1}", PicDir, Path.GetFileName(hpf.FileName.Replace(" ", "_")));
                              bool ex = File.Exists(fullname);
                              if (hpf == (".jpg") || fileExt == (".gif") || fileExt == (".bmp") || fileExt == (".png") || fileExt == (".jpeg"))
                              {
                                  if(FileUpload1.FileBytes.Length &gt; 200000)
                                  {
  
                                      ClientScript.RegisterStartupScript(Type.GetType("System.String"), "messagebox", "&lt;script type=\"text/javascript\"&gt;alert('File Tidak boleh lebih dari 200 kb');&lt;/script&gt;");
                                      break;  
                                  }
  
  
                                  if (ex == true)
                                  {
  
                                      string f = Path.GetFileName(hpf.FileName.Replace(" ", "_"));
                                      string[] a = new string[1];
                                      a = f.Split('.');
                                      filename = string.Format("{0}_{1}.{2}", a.GetValue(0), DateTime.Now.ToString("yymdHm"), a.GetValue(1));
                                  }
  
                                  else
                                  {
                                      filename = Path.GetFileName(hpf.FileName.Replace(" ", "_")).ToString();
  
                                  }
  
                              ///full path name to store in database with new filename
                              //string[] aa = new string[1];
                              //filename = string.Format("{0}_{1}.{2}", aa.GetValue(0), DateTime.Now.ToString("yymdHm"), aa.GetValue(1));
                              fullname = string.Format("{0}\\{1}", PicDir, filename);
                              hpf.SaveAs(fullname); //save as
                              InsertHazardDoc(id_hazard_report, filename);
                              }
                              else
                              {
                                  FileUpload1.Focus();
                                  ClientScript.RegisterStartupScript(Type.GetType("System.String"),"messagebox", "&lt;script type=\"text/javascript\"&gt;alert('File Bukan Format Gambar');&lt;/script&gt;");
                                  break;
                              }
                          }
                       //}
  
                      }
                  }
                      #endregion
  
                      //Page.DataBind();
  
                      myfb._success("Hazard Report Succesfully Inserted");
  
              }
              catch (Exception ex)
              {
                  myfb._error(ex.ToString());
              }
  
          }
  </code></pre>
  
  <p>//  why this code no function if me upload 1.chicken.jpg 180kb 2.chicken.pdf but chicken.pdf follow insert to database </p>