0

I use HttpPostedFileBase as model for the file, but the files comes Null to the controller, I want to use the AjaxForm tha Asp.net provides not the regular BeginForm i need to post this throw ajax ?

   @using (Ajax.BeginForm("UploadImg", "Controller", Object,
  new AjaxOptions { HttpMethod ="Post", OnComplete = "Something();" },
  new { enctype = "multipart/form-data" }))
                {
                    @Html.AntiForgeryToken()

                    <div class="form-horizontal">

                        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                        <div class="form-group">

                            <div class="col-lg-7">
@Html.TextBoxFor(model => model.File, new { type = "file", @class = "form-control", required = "required" })

                <input type="submit" value="Upload" class="btn-primary" />


                            </div>
                        </div>
                    </div>
        }
Wilmar Arias
  • 186
  • 8
  • 1
    show us your controller also – AlexiAmni Aug 06 '18 at 09:00
  • Ajax.Beginform is just a helper function that writes a HTML `
    ` into the markup, so it supports everything that a `
    ` supports
    – Liam Aug 06 '18 at 09:01
  • 1
    Possible duplicate of [MVC 4 Razor File Upload](https://stackoverflow.com/questions/15680629/mvc-4-razor-file-upload) – Liam Aug 06 '18 at 09:02

0 Answers0