For some reason or another, when I add an invalid file extension the error event isn't happening. Did I overlook something?
$(document).ready(() => {
IniUploadJSONFile();
});
function IniUploadJSONFile() {
$("#ImportJSONOrderFile").empty();
$("#ImportJSONOrderFile").kendoUpload({
async: {
//saveUrl: ImportQuote,
autoUpload: false,
multiple: false
},
validation: {
allowedExtensions: [".json"]
},
error: onError
});
}
function onError(e) {
var files = e.files;
for (var i = 0; i < files.length; i++) {
alert("Validation failed for " + files[i].name);
var uid = files[i].uid;
var entry = $(".k-file[data-uid='" + uid + "']");
if (entry.length > 0) {
entry.remove();
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.1.412/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.1.412/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.1.412/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.1.412/styles/kendo.mobile.all.min.css">
<script src="https://kendo.cdn.telerik.com/2022.1.412/js/jszip.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2022.1.412/js/kendo.all.min.js"></script>
<input id="ImportJSONOrderFile" type="file" />
Here is an example that will only accept
.json
file extension. You can run it in the Telerik DOJO.