string PicExtension = "";
string newpic = "";
if (fuUploadFile.PostedFile.ContentLength > 0)
{
string ImageName = fuUploadFile.PostedFile.FileName;
string[] Pic = ImageName.Split('.');
PicExtension = Pic[1].ToString();
newpic = "1" + "." + PicExtension;
string virtualpath = Server.MapPath(@".\UserProfilePic\" + newpic); //Server.MapPath(@".\UserPicPath\" + newpic);
fuUploadFile.PostedFile.SaveAs(virtualpath);
}
It is giving error "Object reference not set to an instance of the object".
Thanx

Mukesh KumarRank #615 · 3.9K reputationPosted Jan 23, 2012, 9:26 PM EST
Try this,
string PicExtension = "";
string newpic = "";
if (fuUploadFile.PostedFile.ContentLength > 0)
{
string ImageName = fuUploadFile.PostedFile.FileName;
string[] Pic = ImageName.Split('.');
PicExtension = Pic[1].ToString();
newpic = "1" + "." + PicExtension;
string virtualpath = Server.MapPath("~/UserProfilePic" + "\\" + newpic);
//string virtualpath = Server.MapPath(@".\UserProfilePic\" + newpic); //Server.MapPath(@".\UserPicPath\" + newpic);
fuUploadFile.PostedFile.SaveAs(virtualpath);
Alok UniyalRank #8,369 · 223 reputationPosted Jan 23, 2012, 9:38 PM EST
File upload control does not works with update panel. So if you are using an update panel, remove it and then try.
The update panel do not work with certain controls.
File upload, and tree view .