HttpFileCollection uploadFilCol = Request.Files;
for(int i=0;i<uploadFilCol.Count;i++)
{
HttpPostedFile file = uploadFilCol[i];
string fileExt = Path.GetExtension(file.FileName).ToLower();
string fileName = Path.GetFileName(file.FileName);
if(fileName != string.Empty)
{
try
{
if(fileExt == ".jpg" || fileExt == ".gif")
{
file.SaveAs(Server.MapPath("./Images/") + fileName);
this.ShowMessage(" " + fileName + " Successfully Uploaded",i);
}
else
{
file.SaveAs(Server.MapPath("./Others/") + fileName);
this.ShowMessage(" " + fileName + " Successfully Uploaded",i);
}
}
catch(Exception ex)
{
this.ShowMessage(" " + ex.Message, i);
}
}
}
Friday, March 20, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment