I have a form in my MVC 3 application that allows the user to optionally upload 2 files (or one or the other) and am looking for a way to tell which file is which if only one of the two files is uploaded (e.g. extracting the element ID from the input). The files serve very different purposes and will be saved to different folders on the server. Both files could potentially be the same file type (Word, PDF, etc), so file extension would not be a reliable way to tell them apart. Is there a way this can be done without making the user give the files a certain filename or something unreliable like that? Here is an example of what I'm trying to do (I know my if statements are not proper syntax. They are just to clarify what I want to do). Thanks everyone!
public ActionResult SaveProfile(IEnumerable<HttpPostedFileBase> files)
.....
foreach (var file in files)
{
if (file has element id "file1") {
file.SaveAs(Server.MapPath("~/Folder1/" + file.FileName));
}
if (file has element id "file2") {
file.SaveAs(Server.MapPath("~/Folder2/" + file.FileName));
}
}
}