Kendo UI异步上传帖子始终为null

时间:2016-01-15 11:19:59

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

我需要从我的html页面上传一个文件async与kendo ui upload。几乎所有这些代码都来自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>

在Controller中保存的操作:

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。

任何人都可以帮我识别出问题所在吗?

1 个答案:

答案 0 :(得分:0)

将保存方法参数类型更改为IEnumerable<IFormFile> files