2
votes

I need to upload a file from my html page async with kendo ui upload. Almost all of this code has been taken from here 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>

Action for save in 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("");
    }

But when I try to debug this the argument files in the controller always == null.

Can anyone help me to identity where the problem is?

1
Problem was in cross-domain. As I understand kendo can't upload file to another domain.Эдуард Посметухов

1 Answers

0
votes

Change your save method parameter type to IEnumerable<IFormFile> files