I'm using kendo-ui upload, I want to filter file (only allow choose .jpg, .png), but I don't know to implement in javascript, please help me! 
1- .cshtml file
<input name="files" id="files" type="file" />
2- JavaScript
$(document).ready(function () {
    $("#files").kendoUpload({
        multiple: false,
        async: {
            saveUrl: "Home/Save"
        }
    });
});
                To filter file, implement as below:
<input name="files" id="files" type="file" accept=".jpg,.png"/>
                        Specify a 'select' event handler when you initialise your kendo upload widget:
$(document).ready(function () {
    $("#files").kendoUpload({
        multiple: false,
        async: {
            saveUrl: "Home/Save"
        },
        select: onSelect,
    });
});
Then use this to handle the file select event:
        function onSelect(e) {
            var files = e.files
            var acceptedFiles = [".jpg", ".jpeg", ".png", ".gif"]
            var isAcceptedImageFormat = ($.inArray(files[0].extension, acceptedFiles)) != -1
            if (!isAcceptedImageFormat) {
                   e.preventDefault();
                   alert("Image must be jpeg, png or gif");
                }
        }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With