Kendo文件上传器没有调用Controller方法

时间:2014-07-08 13:02:41

标签: c# asp.net .net asp.net-mvc-4 kendo-ui

我的文件上传html代码如下:

@using (Ajax.BeginForm("UploadImage", "PP", new AjaxOptions() { HttpMethod = "POST" }, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    <input type="file" name="files">
    <button class="buttoncss">Upload</button>
    //<input type="submit" name="Submit to server">
    (also tried with input type="submit"
}

在PPController中我的方法如下:

[HttpPost]
[ValidateAntiForgeryToken]
public void UploadImage(IEnumerable<HttpPostedFileBase> files)
{
    if (files != null)
    {
        foreach (var file in files)
        {
            // Verify that the user selected a file
            if (file != null && file.ContentLength > 0)
            {
                // extract only the fielname
                var fileName = Path.GetFileName(file.FileName);
                // TODO: need to define destination
                var path = Path.Combine(Server.MapPath("~/Upload"), fileName);
                file.SaveAs(path);
            }
        }
    }

但我的控制器方法没有被调用。

可能是什么问题?

请帮帮我。

0 个答案:

没有答案