i have problem face when i use File Upload Control in Wizard Control.When i use multiple Step in Wizard control and Fileupload Control use at First Step,When i reach at last step then Submit The Information for Save then FileUpload Control Empty or No File.So,The Image Not Save in Database and in Directory.
after to much Search on Net but i Can’t Found solution.After deeply workout then i reach to find the solution.
Solution:
At First Next Step you write the File Upload Code Like
string _ImgName = string.Empty;
//Set Directory Path in Web.config Fiel ,just change Folder Name from WebConfig
string folderPath = ConfigurationManager.AppSettings.Get(“ImagePath”);
string ImgPathimg = Request.PhysicalApplicationPath + folderPath;
fuPicture.EnableViewState = true;
if (fuPicture != null && fuPicture.HasFile)
{
_ImgName = System.IO.Path.GetFileName(fuPicture.PostedFile.FileName);
// This is use for Unique Path for every document
string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + “_”;
string _imgrnd = name + _ImgName;
ImgPathimg = ImgPathimg + _imgrnd;
string name1 = _imgrnd;
ViewState[“ImagePath”] = ImgPathimg;
// fuPicture.SaveAs(ImgPathimg);
// reg.PicturePath = _imgrnd;
ViewState[“ImageName”] = _imgrnd;
}
WizaApplyOnline.ActiveStepIndex = 1;
————————————————–
Save Image Path in View State
ViewState[“ImagePath”] = ImgPathimg;
Save Image Name
ViewState[“ImageName”] = _imgrnd;
After Going Next Step
———————-
————————–
Last Step write this Code……….
if (ViewState[“ImageName”] != null && ViewState[“ImageName”] != string.Empty)
{
fuPicture.SaveAs(ViewState[“ImagePath”].ToString());
// reg.PicturePath = _imgrnd;
reg.PicturePath = ViewState[“ImageName”].ToString();
}
else {
reg.PicturePath = “”;
}
your Problem resolve
Rabeek Ahamed
January 30, 2012 at 1:55 pm
Check the below url to get the fileupload postedfile during postback:
http://forums.asp.net/p/1299780/4806778.aspx/1?p=True&t=634635093043123071