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

Upload e.preventDefault() issue

1 Answer 551 Views
Upload
This is a migrated thread and some comments may be shown as answers.
J
Top achievements
Rank 1
J asked on 23 Feb 2012, 01:12 AM
Hey,

I am trying to prevent users from uploading exe's || zip's, I am calling the below script on the select event .

this.onSelect = function(e) {
$.each(e.files, function(index, value) {
                if(value.extension=='.zip' || value.extension=='.exe') {
                    e.preventDefault();
                    return;
                }
}
}

This prevents the file from appearing in the file list but if I do a submit the zip's are going to the server. I could see input type 'file' elements are getting created even though filelist is not displaying the same. Whats the way around for this

1 Answer, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 23 Feb 2012, 02:54 PM
Hi,

Thank you for reporting this problem. We've fixed it and the fix will be available in the next release. You can use the following workaround for now:
e.preventDefault(e);
setTimeout(function() {
    $("input[name='files']:hidden:last", $("#files").parent()).remove();
});

As a token of gratitude for your involvement your Telerik points have been updated.

All the best,
Tsvetomir Tsonev
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
J
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Share this question
or