upload validation

2 posts, 0 answers
  1. Borislav
    Borislav avatar
    1 posts
    Member since:
    Nov 2011

    Posted 30 Jan 2012 Link to this post

    Hi
    I have this annoying problem when trying to validate the upload file type.
    I got the alert all the time.

    This is the code I use:

    $(document).ready(function(){
    $("#contact-form").kendoValidator();
    $("#files").kendoUpload({
    multiple: false,
    select: onSelect
    });

    function onSelect(e) {
    // Array with information about the uploaded files
    var files = e.files;


    if (this.extension != ".jpg") {
                alert("Only .jpg files can be uploaded")
                e.preventDefault();
            }
    }
    });

    Regards!
    B.
  2. Dimo
    Admin
    Dimo avatar
    8474 posts

    Posted 30 Jan 2012 Link to this post

    Hello Borislav,

    extension is a property of each of the selected files, not of "this". You should be checking something like this:

    e.files[0].extension

    (for example in a loop)

    http://www.kendoui.com/documentation/ui-widgets/upload/events.aspx

    Greetings,
    Dimo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top