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
Alok UniyalPosted Jan 24, 2012, 2:38 AM
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 .
Mukesh KumarPosted Jan 24, 2012, 2:26 AM
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);