Thursday, March 29, 2012

Best way to Upload Images in asp.net

Hi all,
Some of our blog members are working on asp.net ,I am receiving the information most of the times about uploading the Images in asp.net as far as I am concern below code is the best way to upload the image which accepts any extension.

string imgname = FileUpload1.FileName;
string path =Server.MapPath ("~/Images")+"//"+imgname;
FileUpload1.SaveAs(path);
Image1.ImageUrl = "Images/" + FileUpload1.PostedFile.FileName;