This is a migrated thread and some comments may be shown as answers.

Kendo UI Upload Not Accepting File Types

1 Answer 507 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Abdullah
Top achievements
Rank 1
Abdullah asked on 03 Feb 2016, 10:14 PM

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("");
        }

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 04 Feb 2016, 08:16 AM

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!
 
Ravi
Top achievements
Rank 1
commented on 31 Dec 2024, 06:14 PM

Telerik Team, We are facing same issue, but we are using Aspnet.core version of telerik controls. 
We are only able to upload txt files, when we explicitly declared the upload with AllowedExtensions to include png, xls, doc, pdf etc. 

We receive 403 Forbidden in the dev tools.

Any recommendations to fix this issue ?

Eyup
Telerik team
commented on 02 Jan 2025, 05:21 PM

Hi Ravi,

I have tested this behavior using the following property:

                .Validation(validation =>
                {
                    validation.AllowedExtensions(new string[] { "txt" });
                })
And it doesn't allow anything other than txt:

Can you check the sample I have prepared and let me know if it helps you?
https://netcorerepl.telerik.com/cTkPacbV21n3tfPa18

 

Tags
Upload
Asked by
Abdullah
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or