【问题标题】:using Ajax.js and JQuery.js post multiple file as null使用 Ajax.js 和 JQuery.js 将多个文件发布为 null
【发布时间】:2018-08-27 17:36:17
【问题描述】:

我想使用包含 input type="file" 多个的 Ajax.BeginForm。但是如果我将文件值发送给控制器,则文件值为空。因为一起使用 JQuery.js 和 Ajax.js。如果我在此查看文件中删除 Jquery 值不为空。

@{
   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>

//控制器

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

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

        return PartialView("veriler",ViewBag.a);
    }

【问题讨论】:

  • 您好,欢迎使用堆栈溢出,请不要分享代码图像,因为它没有帮助,直接在这里添加代码。避免外部链接,或者只是创建一个 sn-p 并在此处添加链接
  • 好吧!我编辑了它
  • 这是在 asp.net 中吗?对

标签: jquery ajax file null


【解决方案1】:

您不能使用 AJAX 上传文件。这是不支持的。如果您想这样做,您可以使用一些文件上传插件,例如UploadifyBlueimp File Upload,或者如果客户端浏览器支持,则使用HTML 5 File API

Answer from

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-14
    • 1970-01-01
    • 1970-01-01
    • 2016-01-04
    • 2014-09-21
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    相关资源
    最近更新 更多