Kendo UI Upload Not Accepting File Types

2 posts, 1 answers
  1. Abdullah
    Abdullah avatar
    1 posts
    Member since:
    Sep 2013

    Posted 03 Feb Link to this post

    Hello,

     I have this issue, I am trying to upload files via kendo upload and if the file format is .txt it is uploading the file properly. When I tried the same with .pdf, it always fails. I even tried all other file types like .doc, .xls, .csv etc. but they keep failing. I don't know what I am doing wrong. The following is my implementation of kendo Upload.

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

    JQUERY: $("#files").kendoUpload(
            {
                multiple:true,
                //upload: onUpload,
                async: {
                    saveUrl: "/Bank/Save",
                    //removeUrl: "/Bank/Remove",
                    autoUpload: true,
                }
            });

    C#:  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(@"C:\New Folder\", fileName);  //Server.MapPath("~/App_Data")

                        // The files are not actually saved in this demo
                        file.SaveAs(physicalPath);
                    }
                }

                // Return an empty string to signify success
                return Content("");
            }

            public ActionResult Remove(string[] files)
            {
                // The parameter of the Remove action must be called "fileNames"

                if (files != null)
                {
                    foreach (var fullName in files)
                    {
                        var fileName = Path.GetFileName(fullName);
                        var physicalPath = Path.Combine(@"C:\New Folder\", fileName);

                        // TODO: Verify user permissions

                        if (System.IO.File.Exists(physicalPath))
                        {
                            // The files are not actually removed in this demo
                            System.IO.File.Delete(physicalPath);
                        }
                    }
                }

                // Return an empty string to signify success
                return Content("");
            }

     

  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 04 Feb Link to this post

    Hello Abdullah,

    The Upload widget itself does not restrict the file types to be uploaded, so the reason for the issue seems to be a configuration property on the server side. I would suggest to open the network tab of the browsers developer tools and check the response for one of the Upload requests. This will hint what is the actual reason for the problem.

    Regards,
    Dimiter Madjarov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
Back to Top