I am new to MVC, and I have an issue that I can't seem to resolve. I have seen several articles on similar issues, but nothing that I can make fit the bill for what I need to achieve.
I have an MVC4 project, and I need to have multiple multi-file inputs on a page, and I need to be able to distinguish between which files were submitted via which input.
I have seen this SO article that suggested having multiple Post action args, but my code seems to handle them all as a single list.
Here is my controller code :
public ActionResult ProjectDocuments(C4Tbl_UploadedFiles c4tbl_uploadedfiles, IEnumerable<HttpPostedFileBase> File1, IEnumerable<HttpPostedFileBase> File2)
{
try
{
foreach (var file in File1)
{
if (file.ContentLength > 0)
{
//Handle the first file list
}
}
foreach (var file in File2)
{
if (file.ContentLength > 0)
{
//Handle the second file list
}
}
Here is my View code :
<table border="0" id="cssTable" class="nobg">
<tr>
<th style="width: 100px; min-width: 100px; max-width: 100px">
<b>Type</b>
</th>
<th style="width: 400px; min-width: 400px; max-width: 400px">
<b>File to Upload</b>
</th>
<th style="width: 500px; min-width: 500px; max-width: 500px">
<b>Status</b>
</th>
</tr>
<tr>
<td style="width: 100px; min-width: 100px; max-width: 100px">
<b>Blueprint(s)</b>
</td>
<td style="width: 400px; min-width: 400px; max-width: 400px">
<input type="file" name="File1" id="BP" multiple style="width: 380px"/>
</td>
<td style="width: 500px; min-width: 500px; max-width: 500px; text-align: left">
@Html.RadioButton("Submitted", "Yes", false, new { @style = "width: 25px;", groupname="group1" }) Uploaded
@Html.RadioButton("Submitted", "No", false, new { @style = "width: 25px;", groupname="group1" }) Not Uploaded
@Html.RadioButton("Submitted", "N/A", false, new { @style = "width: 25px;", groupname="group1" }) Not Applicable
</td>
</tr>
<tr>
<td style="width: 100px; min-width: 100px; max-width: 100px">
<b>Recovery Guide(s)</b>
</td>
<td style="width: 400px; min-width: 400px; max-width: 400px">
<input type="file" name="File2" id="RG" multiple style="width: 380px"/>
</td>
<td style="width: 500px; min-width: 500px; max-width: 500px; text-align: left">
@Html.RadioButton("Submitted", "Yes", false, new { @style = "width: 25px;", groupname="group2" }) Uploaded
@Html.RadioButton("Submitted", "No", false, new { @style = "width: 25px;", groupname="group2" }) Not Uploaded
@Html.RadioButton("Submitted", "N/A", false, new { @style = "width: 25px;", groupname="group2" }) Not Applicable
</td>
<td>
<input type="submit" value="Submit" name="submit" />
</td>
</tr>
</table>
I need to be able to accept any or all of the Inputs having files provided, and I need to know which of my inputs the files were submitted via, so I know which type of file they are so I can create the relevant DB entries in my tables.
Can anyone see a simple solution for this and point me in the right direction?