I am using Kendo uploader to upload files into my application. I have made sure to allow only the extensions defined in my config to be allowed to upload or else to show up an error message. My code looks something like this
var validExtensions = [".pdf", ".doc", ".docx", ".pptx", ".xls", ".xlsx", ".txt"];
$('#uploader').kendoUpload({
multiple: false,
select: function (e) {
if (validExtensions.indexOf(e.files[0].extension.toLowerCase()) <= -1) {
alert("File type not allowed!");
e.preventDefault();
return false;
}
}
});
This works fine to accept files of only the given extensions. But there is an issue raised by the security team who are evaluating to avoid files with multiple extensions to be uploaded (e.g. fileName.msi.txt
or fileName.exe.doc
) should not be allowed.
I know we can split based on . and evaluate but I wanted to know in case we have a cleaner way to achieve this?
Thanks