HttpPost, ActionName("AddProjectPlan")] //don't really understand this?
public void Add()
{
foreach (string file in Request.Files) //only posting one element from the form, but this would work for many
{
HttpPostedFileBase postedFile = Request.Files[file] as HttpPostedFileBase;
if (postedFile.ContentLength > 0) //if file not empty
{
//create an XML object for loading in the project plan xml
XmlDocument xmlProjPlan = new XmlDocument();
try
{
xmlProjPlan.Load(postedFile.InputStream);
Response.Write("File " + postedFile.FileName + " successfully loaded
");
}
catch
{
Response.Write("File " + postedFile.FileName + " is not valid XML
");
}
//Response.Write(xmlProjPlan.InnerXml); //for debugging
}
else
{
// Let user know there was a problem
Response.Write("No file submitted or file zero length");
}
}
}
}
No comments:
Post a Comment