Multiple File Upload

HttpFileCollection uploadFilCol = Request.Files;
02.for(int i=0;i<uploadFilCol.Count;i++)
03.{
04.  HttpPostedFile file = uploadFilCol[i];
05.  string fileExt = Path.GetExtension(file.FileName).ToLower();
06.  string fileName = Path.GetFileName(file.FileName);
07.  if(fileName != string.Empty)
08.  {
09.    try
10.    {
11.      if(fileExt == ".jpg" || fileExt == ".gif")
12.      {
13.        file.SaveAs(Server.MapPath("./Images/") + fileName);
14.        this.ShowMessage(" " + fileName + " Successfully Uploaded",i);
15.      }
16.      else
17.      {
18.        file.SaveAs(Server.MapPath("./Others/") + fileName);
19.        this.ShowMessage(" " + fileName + " Successfully Uploaded",i);
20.      }
21.    }
22.    catch(Exception ex)
23.    {
24.      this.ShowMessage(" " + ex.Message, i);
25.    }
26.  }
27.}

Comments

Popular posts from this blog

ASP.NET Session States in SQL Server Mode

How to find client's MAC Address in Asp.Net and C#.net

Use XML Data For Save in Database