我需要从我的 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。
谁能帮我确定问题出在哪里?
将保存方法参数类型更改为IEnumerable<IFormFile> files