I'm using MVC4 on IIS8.0 to POST multiple image files to a server. This has been working for a long time, but recently the application needed to change where it saved the images. Before, I was saving to a Network location, and now I am saving directly to the same webserver where the application is running.
Now when I upload only one file gets saved. Specifically the last file in the list.
Why is this now happening? Also, I can run the application on localhost and it will save all images to the web server just fine. Once I publish and try it, it starts only taking the final image again.
From HTML:
<form id="inputForm" method="post" action="../images/Create" enctype="multipart/form-data">
<div id="uploadList">
<input type="file" name="files" id="file1" accept=".jpg,.png,.gif" />
<input type="file" name="files" id="file2" accept=".jpg,.png,.gif" />
<input type="file" name="files" id="file3" accept=".jpg,.png,.gif" />
<input type="file" name="files" id="file4" accept=".jpg,.png,.gif" />
<input type="file" name="files" id="file5" accept=".jpg,.png,.gif" />
<input type="file" name="files" id="file6" accept=".jpg,.png,.gif" />
</div>
Here are a few of the lines from web.config.
<system.web>
<httpRuntime targetFramework="4.5" maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
From the Controller.
[HttpPost]
public ActionResult Create(IEnumerable<HttpPostedFileBase> files, string serial)
//... Other stuff
foreach (var file in files)
{
if (file != null)
{
if (file.ContentType == "image/jpeg" || file.ContentType == "image/png" || file.ContentType == "image/gif")
{
var fileName = Path.GetExtension(file.FileName);
string result = fileName.AppendTimeStamp();
var path = Path.Combine((Server.MapPath("~/adpear\\") + storageLoc + "\\" + theUserCompany + "\\" + serial), (serial + "_" + result));
file.SaveAs(path);
theSavedImageCount++;
}
}
}