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

upload validation

1 Answer 234 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Borislav
Top achievements
Rank 1
Borislav asked on 30 Jan 2012, 12:09 PM
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.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 30 Jan 2012, 05:57 PM
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!
Tags
Upload
Asked by
Borislav
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or