2

我需要从我的 html 页面上传一个与剑道 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。

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

4

1 回答 1

0

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

于 2019-03-03T15:22:14.257 回答