0

I'm trying to upload a file from my view to my controller, but the value is always null.

Controller:

public ActionResult Edit(AttachmentDto dto, HttpPostedFileBase UploadedFile)

Form Tag:

<form action="@Url.Action("Edit")" method="post" enctype="multipart/form-data">

Input Tag:

<input type="file" name="UploadedFile" id="File"  />

There are few other inputs being passed into the controller that the dto is receiving, however the UploadedFile is always null? Am I missing something here?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ThePugh
  • 26
  • 4

1 Answers1

0

So the mystery turned out to be a JavaScript import that was added to the project by a colleague to handle our form posts. There is already a question regarding posting multipart/formdata using jQuery here: Sending multipart/formdata with jQuery.ajax

Just added the FormData object and presto.

Thanks for all of your help!

ThePugh
  • 26
  • 4