-1

I want to use Ajax.BeginForm which contains a input type="file" multiple. But file value is null if i send it to controller. Because using together JQuery.js and Ajax.js. If I delete Jquery in this View file value not null.

@{
   ViewBag.Title = "Home Page";
}

<script src="~/Scripts/jquery-3.3.1.js"></script>

<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>

@using (Ajax.BeginForm("Send", "Home",new AjaxOptions { UpdateTargetId="result",HttpMethod="POST",InsertionMode=InsertionMode.Replace},new {enctype="multipart/form-data" }))
{
    <input name="name"  />

    <input   id="files" name="pictures" type="file" multiple />
    <button type="submit"  >SEND</button>

}

<div id="result"></div>

//Controller

 [HttpPost]
    public PartialViewResult Send(string name,IEnumerable<HttpPostedFileBase> pictures)
    {

        //int sayi = resimler.Count();
        ViewBag.a = "abcsados";

        return PartialView("veriler",ViewBag.a);
    }
3
  • Hi Welcome to stack overflow, please don't share code images because its not helpful, add code here directly. avoid external links, or just create a snippet and add link to it here Commented Aug 27, 2018 at 9:19
  • Okey! I edited it Commented Aug 27, 2018 at 9:23
  • is this in asp.net? right Commented Aug 27, 2018 at 9:34

1 Answer 1

0

You cannot upload files using AJAX. This is not supported. If you want to do that you could either use some file upload plugin such as Uploadify or Blueimp File Upload or use the HTML 5 File API if the client browser supports it.

Answer from

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.