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.}
No comments:
Post a Comment