Hello there!,
I am having trouble in receiving the attached files from a html file input !.
First of all i have added a master page and made this form as a content page!
Actaully the view state of this html file input is not maintaining when the page is posted back!. It says Request.Files.Count=0 even i had attached a file!
Before adding the master page it worked fine!
Could you please tell me a solution!,
My Code is
if (Request.Files.Count != 0)
{
HttpFileCollection files = Request.Files;
DataTable Table4 = new DataTable();
DataColumn Doc_Name = new DataColumn();
Doc_Name.ColumnName = "Documents";
DataColumn Remove = new DataColumn();
Remove.ColumnName = "Remove";
Table4.Columns.Add(Doc_Name);
Table4.Columns.Add(Remove);
for (int p = 0; p < files.Count; p++)
{
HttpPostedFile file = files[p];
if (file.ContentLength == 0)
{
continue;
}
string c = System.IO.Path.GetFileName(String.Format(file.FileName));
string path = Server.MapPath("../")+"Upload"+ @"\" +c;
StreamWriter streamWriter;
streamWriter = File.CreateText(path);
streamWriter.Close();
file.SaveAs(path);
Table4.Rows.Add(p);
Table4.Rows[p]["Documents"] =c;
Table4.Rows[p]["Remove"] = "Remove";
}
Session["DOC_INFO"] = Table4;
}
Praveen VenugopalPosted Aug 23, 2008, 2:16 AM
Thanks For ur relpy!,
Actaully the view state of the html file input is not getting maintained!,
Because i have made my webform as a content page to a master page.
Earlier my web form worked fine!
karthik palanivelPosted Aug 23, 2008, 1:27 AM
Hi,
u can use the runat="server" in ur HTML input file tag and access the input file in asp.net page. and check whether the file has added or not.