HttpPostedFile is null

So you have your action ready to receive your data from your HTML file inputs but the array values for the files are coming in as null?

public ActionResult Save(MyModel model, HttpPostedFileBase[] attachedFiles)

Just add enctype = "multipart/form-data" to your form tag.

@using (Html.BeginForm("Save", "MyController", FormMethod.Post, new { enctype = "multipart/form-data" })) {

Notice the anonymous object is AFTER the FormMethod parameter! Excluding this parameter will pass the object in as the action parameters, not HTML attributes.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s