
Announcements
Hi Guys,
I would like to prevent certain file types which are basically double file extension to not be uploaded in the Portal application. (e.g. abc.exe.txt). Can you kindly guide me how to achieve that in portal without using Jquery. I have following configuration in the Form's additional settings for configuring notes. However, I do not see how I can restrict double file extension here or in the Entity Form Metadata.
Attach File - Yes
Attach File Storage Location - Note Attachment
Allow Multiple Files - Yes
Accept MIME Types - application/pdf;image/jpeg;image/png
Accept File Types - .xlsx,.xls,.doc,.docx,.ppt,.pptx,.txt,.pdf,.csv,.pps
I am doing similar to one of my Portals, but basically the idea is to reject certain characters from the file name.. you can probably use same logic to validate the extension
I am using that function in the usual form validator
InvalidFilenameValidationError = function (inputName, errorMessage) {
var invalidCharacters = ['#', '%', '*', ':', '<', '>', '?', '/', '|', '\''];
var files = $("#" + inputName)[0].files;
//check that files has correct names
for (var i = 0; i < files.length; i++) {
var file = files[i];
for (var character = 0; character < invalidCharacters.length; character++) {
if (file.name.indexOf(invalidCharacters[character]) > -1) {
// show error message here
return false;
}
}
}
return true;
};