Kendo Upload file to C# Web Method

2 posts, 0 answers
  1. Canton
    Canton avatar
    4 posts
    Member since:
    Sep 2012

    Posted 18 Jun 2015 Link to this post

    I am using a Kendo upload to save files to my server. However, I would like to send the files to a C# web method in a web service where I then perform the code that saves the files to the server.

    I am having difficulty when trying to call my web method.

    Here is what I have:

            //Saves attachment files to server
            public string UploadAttachments(IEnumerable<HttpPostedFileBase> files)
                string returnMessage = "Copying Attachments...";
                      // The Name of the Upload component is "files"
                if (files != null)
                    foreach (var file in files)
                        // Some browsers send file names with full path.
                        // We are only interested in the file name.
                        var fileName = Path.GetFileName(file.FileName);
                        var physicalPath = Path.Combine(Server.MapPath("~/App_Data/Attachments"), fileName);
                catch (Exception e)
                    returnMessage = "Fail";

                return returnMessage;

            } //End


    Here is the upload input on my webpage and the javascript I am using:

    <input id="files" type="file" name="files" />

            //when adding attachments
            $(document).ready(function () {
                    async: {
                        saveUrl: "../WebService.asmx/UploadAttachments",
                        removeUrl: "remove",
                        multiple: true,
                        autoUpload: true


    I cannot get it to call my method when trying to pass the "IEnumerable<HttpPostedFileBase> files" , but it will hit the method if I take that part out, but then I cannot perform the rest of the code within the method.

    Currently, when I try to upload a file, it automatically says it has failed and never calls my web method.

    Am I missing a step somewhere?


  2. Boyan Dimitrov
    Boyan Dimitrov avatar
    2062 posts

    Posted 22 Jun 2015 Link to this post

    Hello Canton,


    Please refer to the answer in the following thread and the provided demo. 


    Boyan Dimitrov
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top