AllowedFileExtensions case insensitive?

7 posts, 0 answers
  1. Martin
    Martin avatar
    34 posts
    Member since:
    Oct 2012

    Posted 30 Mar 2015 Link to this post

    AllowedFileExtensions on RadAsyncUpload is case sensitive. So when setting AllowedFileExtensions to "doc, docx" it won't accept any DOC or DOCX extensions. How can I enable AllowedFileExtensions to be case insensitive?
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 02 Apr 2015 Link to this post

    Hi Martin,

    I have tested the scenario that you are describing and everything is working correctly on my end and the the file extensions are case insensitive.

    Can you please elaborate which version of our controls you are using? If it is an old version, please upgrade to our latest versions and see if you will continue to face the same problem.


    Regards,
    Konstantin Dikov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kallie
    Kallie avatar
    2 posts
    Member since:
    Aug 2013

    Posted 02 Jul 2015 Link to this post

    Hi,

    I am experiencing the same problem.

    Here is how I have defined my RadAsyncUpload 

     <telerik:RadAsyncUpload ID="FileUpload" runat="server" OnFileUploaded="FileUpload_FileUploaded"
                                                     AllowedFileExtensions="pdf,png,gif,tif,dox,xlsx,xls,doc,docx" MultipleFileSelection="Automatic" PostbackTriggers="btnUpload"
                                                    Style="text-align: center;" />
                                                <telerik:RadButton runat="server" ID="btnUpload" Text="Upload" />

    But it's failing for all except PDF? Do I need to add something?

    Please see attached output after Files have been selected.

    Thanks in advance

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 06 Jul 2015 Link to this post

    Hi Kallie,

    Can you please try once again to upload the screenshot that you are referring to? Additionally, can you elaborate on the version that you are currently using, because with our latest versions there is no problem with the case sensitivity of the file extensions.

    On a side note, you can also test our online demo, where you can upload files with case insensitive file extension:
    I am looking forward to your reply.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Ray
    Ray avatar
    10 posts
    Member since:
    Jun 2014

    Posted 22 Oct 2015 in reply to Konstantin Dikov Link to this post

    Hello,

    I am experiencing the same thing, however I cannot explain it.  It is in the javascript client-side validation that it is happening.

    So far, it is happening just for "JPG" vs "jpg".  For instance both "txt" and "TXT" work and I only have "txt" in the allowed file extensions list.  If the file's extension is "JPG" and I only have "jpg" in the allowed file extensions, the javascript function detects -1 and throws the "This file type is not supported." error.

     Here is the js function that I am using:

                function getErrorMessage(sender, args) {
                    var fileExtention = args.get_fileName().substring(args.get_fileName().lastIndexOf('.') + 1, args.get_fileName().length);
                    if (args.get_fileName().lastIndexOf('.') != -1) {//this checks if the extension is correct
                        if (sender.get_allowedFileExtensions().indexOf(fileExtention) == -1) {
                            return ("This file type is not supported.");
                        }
                        else {
                            return ("This file exceeds the maximum allowed size of 80 KB.");
                        }
                    }
                    else {
                        return ("not correct extension.");
                    }
                }

    I am using Telerik.Web.UI v2015.2.623.45.

    If I set the allowed file extensions like this:

    AllowedFileExtensions="txt,jpg,JPG"

    it does not throw the error.

    Any suggestions as to why this is happening would be appreciated.

    Thanks,

    Ray Goforth

     

  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 26 Oct 2015 Link to this post

    Hi Ray,

    For such client-side validation you should use the following condition instead:
    if (sender.get_allowedFileExtensions().toLowerCase().indexOf(fileExtention.toLowerCase()) == -1) {
        return ("This file type is not supported.");
    }

    Please give it a try and let me know if the issue is resolved.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  8. Ray
    Ray avatar
    10 posts
    Member since:
    Jun 2014

    Posted 26 Oct 2015 in reply to Konstantin Dikov Link to this post

    Hi Konstantin,

    Thanks very much for the code.  This does resolve the issue but I see why some people are experiencing this case sensitivity when others are not.  The issue only happens when the maximum size has been exceeded.  For instance:

    Lets say that my allowed file types is "jpg" and my max size is 80kb.

    If I try to upload a file "test.jpg" that is 85kb, the error says "This file exceeds the maximum allowed size of 80 KB.", which makes sense.

    If I rename the file to "test.JPG" and try to upload it, the error says "This file type is not supported." 

     

    Thanks for your help!

     Ray Goforth

     

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017