【问题标题】:Kendo UI async upload post always nullKendo UI 异步上传帖子始终为空
【发布时间】:2016-01-15 11:19:59
【问题描述】:

我需要从我的 html 页面上传一个与 kendo ui 上传异步的文件。几乎所有这些代码都取自这里http://demos.telerik.com/kendo-ui/upload/async

HTML

<div id="example">      
        <div>
            <div class="demo-section k-content">
                <input name="files" id="files" type="file" />
            </div>
        </div>
        <script>
            $(document).ready(function() {
                $("#files").kendoUpload({
                    async: {
                        saveUrl: "http://localhost:57016/DownloadUsingFile/Save",
                        removeUrl: "remove",
                        autoUpload: true
                    }
                });
            });
        </script>
    </div>

控制器中保存的操作:

public ActionResult Save(IEnumerable<HttpPostedFileBase> files)
    {
        // The Name of the Upload component is "files"
        if (files != null)
        {
            foreach (var file in files)
            {
                // Some browsers send file names with full path. This needs to be stripped.
                //var fileName = Path.GetFileName(file.FileName);
                //var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);

                // The files are not actually saved in this demo
                // file.SaveAs(physicalPath);
            }
        }

        // Return an empty string to signify success
        return Content("");
    }

但是当我尝试调试时,控制器中的参数文件总是 == null。

谁能帮我确定问题出在哪里?

【问题讨论】:

  • 问题出在跨域中。据我了解,剑道无法将文件上传到另一个域。

标签: asp.net-mvc kendo-ui kendo-upload


【解决方案1】:

将保存方法参数类型更改为IEnumerable&lt;IFormFile&gt; files

【讨论】:

  • 对我不起作用。切换到 IEnumerable. 后仍然为空
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-05
  • 2015-06-04
  • 1970-01-01
相关资源
最近更新 更多