title: how to select multiple images using FileUpload conrol in framework 4.0 in asp.net c#
body: <p>I am trying to upload more than one image using <code>FileUpload</code> control but not able to do it</p>
  
  <p>i tried:</p>
  
  <pre><code>&lt;asp:FileUpload ID="fuImage" AllowMultiple="true" runat="server"/&gt;
  </code></pre>
  
  <p>and this also :</p>
  
  <pre><code>&lt;asp:FileUpload ID="fuImage" multiple="multiple" runat="server"/&gt;
  </code></pre>
  
  <p>but as i searched for hours on google,i found that this is only working for version 4.5 not in 4.0</p>
  
  <pre><code>protected void btnAdd_Click(object sender, EventArgs e)
      {
          if (fuimage.HasFile)
          {
              string fname = fuimage.FileName;
              string path = Server.MapPath("~/EventPics/");
              string fext = Path.GetExtension(fname);
              fext = fext.ToLower();
              string link = "~/EventPics/" + fname;
              if (fext == ".jpg" || fext == ".png" || fext == ".gif" || fext == ".bmp")
              {
                  fuimage.SaveAs(path + fname);
                  con = new SqlConnection(ConfigurationManager.ConnectionStrings["WebAAERT_DBConnectionString"].ConnectionString);
                  SqlCommand cmd;
  
                  //create command
                  cmd = new SqlCommand("EventMasterInsert", con);
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.Parameters.AddWithValue("@ImagePath", link);
                  cmd.Parameters.AddWithValue("@EventTitle", txtEventTitle.Text);
                  cmd.Parameters.AddWithValue("@EventDate", txtEventDate.Text);
                  cmd.Parameters.AddWithValue("@EventPlace", txtPlace.Text);
                  cmd.Parameters.AddWithValue("@ShortDescription", txtShort.Text);
                  cmd.Parameters.AddWithValue("@Description", txtDesc.Text);
                  cmd.Parameters.AddWithValue("@EventTime", txtTime.Text);
                  //open connection
                  cmd.Connection = con;
                  con.Open();
  
                  //execute command
                  int rowcount = cmd.ExecuteNonQuery();
                  if (rowcount &gt; 0)
                  {
                      Response.Write("&lt;script&gt;alert('Event Added');&lt;/script&gt;");
                      txtDesc.Text = "";
                      txtEventDate.Text = "";
                      txtEventTitle.Text = "";
                      txtPlace.Text = "";
                      txtShort.Text = "";
                      txtTime.Text = "";
  
  
                  }
              }
          }
  </code></pre>
  
  <p>i tried</p>
  
  <pre><code> foreach(item in fuImage.postedFile)
  {
  }
  </code></pre>
  
  <p>but its not working.. no idea how to do it in most easy way..</p>