ASP.NET MVC4多个文件上传不能从移动设备工作

本文关键字:不能 移动 工作 MVC4 NET 文件 ASP | 更新日期: 2023-09-27 18:05:34

我有以下代码,可以从url: http://nirh1989-001-site1.itempurl.com/输入网站

当我从桌面打开url时,我可以一次上传多个文件,但是当我从移动浏览器打开url时,我一次只能上传一个文件。

为什么?

Index.cshtml:

@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="container">
        <div class="form-horizontal">
            <div class="form-group">
                <p></p>
                <label for="file">Upload Photo:</label>
                <input type="file" name="file" id="file" accept="image/*" multiple="multiple" required />
            </div>
            <div class="form-group">
                <div>
                    <input type="submit" value="Upload" class="btn btn-default" />
                </div>
            </div>
        </div>
    </div>
    <hr />
    <div class="gallery">
        @if (ViewBag.Images != null)
        {
            var imgID = 0;
            foreach (var image in (IEnumerable<string>)ViewBag.Images)
            {
                imgID++;
                <a class="fancybox" rel="group" href="@Url.Content(image)">
                    <img id="@imgID" src="@Url.Content(image)" style="height: 100px; width: 100px;" />
                </a>
            }
        }
    </div>
}

控制器:

public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            ViewBag.Images = Directory.EnumerateFiles(Server.MapPath("/Content/Photos")).Select(f => "/Content/Photos/" + Path.GetFileName(f));
            return View();
        }
        //POST: Home
        [HttpPost]
        public ActionResult Index(IEnumerable<HttpPostedFileBase> file)
        {
            if (file != null)
            {
                foreach (var item in file)
                {
                    string fileName = Path.GetFileName(item.FileName);
                    string imgPath = Server.MapPath("~/Content/Photos/");
                    item.SaveAs(imgPath + fileName);
                }
            }
            ViewBag.Images = Directory.EnumerateFiles(Server.MapPath("/Content/Photos")).Select(f => "/Content/Photos/" + Path.GetFileName(f));
            return View();
        }
    }

ASP.NET MVC4多个文件上传不能从移动设备工作

显然我的代码没有任何问题…问题出在手机上,我试图从手机的一个文件夹中上传多个文件,由于某种原因,不允许多个选项…尝试从图库上传,一切正常