My source file is:
and code behind code is:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string Prefix = DateTime.Now.ToString("ddMMyyhhmmsstt");
string Doc_Name = (Path.GetFileName(FileUpload1.PostedFile.FileName)).Split('.')[0].ToString();
string str = FileUpload1.FileName;
string targetPath = Server.MapPath("~\\images\\Docs\\") + Prefix + FileUpload1.FileName;
FileUpload1.SaveAs(targetPath);
}
}
{
if (FileUpload1.HasFile)
{
string Prefix = DateTime.Now.ToString("ddMMyyhhmmsstt");
string Doc_Name = (Path.GetFileName(FileUpload1.PostedFile.FileName)).Split('.')[0].ToString();
string str = FileUpload1.FileName;
string targetPath = Server.MapPath("~\\images\\Docs\\") + Prefix + FileUpload1.FileName;
FileUpload1.SaveAs(targetPath);
}
}
My problem is that FileUpload1.HasFile return false, why ?
And how can fix it and save the file in folder.
Please help me...
Thanks in advance.


Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 19, 2015, 10:46 PM EDT
Santhakumar MunuswamyRank #128 · 17.3K reputationPosted Jun 17, 2015, 7:36 PM EDT
Nilesh JadavRank #109 · 20.3K reputationPosted Jun 17, 2015, 11:11 PM EDT
Yes it will return false, this is because of - "Postback" -
you have to use - "Triggers " like this :
Hope it works , Mark accepted if it works
Thank you
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 17, 2015, 11:57 PM EDT
{
if (FileUpload1.HasFile)
{
string Prefix = DateTime.Now.ToString("ddMMyyhhmmsstt");
string Doc_Name = (Path.GetFileName(FileUpload1.PostedFile.FileName)).Split('.')[0].ToString();
string str = FileUpload1.FileName;
string targetPath = Server.MapPath("~\\images\\Docs\\") + Prefix + FileUpload1.FileName;
FileUpload1.SaveAs(targetPath);
}
}
Munesh SharmaRank #174 · 13.9K reputationPosted Jun 18, 2015, 12:48 AM EDT
Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 19, 2015, 10:07 PM EDT
Jaipal ReddyRank #588 · 4.1K reputationPosted Jun 19, 2015, 10:08 PM EDT
Rahul PrajapatRank #1,209 · 1.5K reputationPosted Jun 19, 2015, 10:25 PM EDT
Nilesh JadavRank #109 · 20.3K reputationPosted Jun 19, 2015, 10:43 PM EDT
Still you have problem then refer this link :
http://www.aspsnippets.com/Articles/Using-FileUpload-Control-inside-ASP.Net-AJAX-UpdatePanel-Control.aspx
Thank you !