0

I have a very basic multiple file uploader that works on Firefox and IE but on Chrome it hangs when I include the name="files" attribute in the input tag below. Has anyone else experienced this problem? and if so is there a work around?

<form action="/AdminFileUpload/PostMultiple" method="post" enctype="multipart/form-data">

    <input id="fileupload" type="file" name="files" multiple="multiple" />
    <input type="submit" name="submit" value="Upload" />
    <hr />
    <b>Live Preview</b>
    <br />
    <br />
    <div id="dvPreview">
    </div>
</form>

This is the controller I am using; If I remove name="files" from the input tag the IEnumerable<HttpPostedFileBase> files parameter in the controller is null.

    [HttpPost]
    public ActionResult PostMultiple(IEnumerable<HttpPostedFileBase> files)
    {
        foreach (var file in files)
        {
            if (file != null && file.ContentLength > 0)
            {
                file.SaveAs(Path.Combine(Server.MapPath("/Uploads"), Path.GetFileName(file.FileName)));
            }
        }

        return RedirectToAction("Index");
    }

0 Answers0