【发布时间】: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 中吗?对