I want to allow my user to upload different documents using different upload button.
My question: Is there any way that I can get the type of document being uploaded?
Consider a scenario: My user may upload their Resume by clicking on resume upload button & user may upload cover letter by clicking on Upload cover letter button.
How would I know whether the uploaded content is resume or cover letter.
All I get in the controller is HttpPostedFileBase[]
.
[HttpPost]
public ActionResult Create(FormCollection collection, HttpPostedFileBase[] upload)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
One question I found similar to my question is: Get file names from multiple files uploaded. The approach they are following, is it efficient? I mean I will have 8-10 Upload buttons on my page. Having 8-10 parameters in Post method looks odd.