
Hi All,
I know , we have property called "AllowedFileExtensions" specify the allowed extensions. but i have list of extensions which need to be blocked like .ADE,ADP,BAS,BAT,CHM,CMD,COM,CPL,CRT,EXE,HLP,HTA,INF,INS,ISP,JS so on.....list goes upto 38 extensions. How to block this list of extensions for RadAsyncupload control......
6 Answers, 1 is accepted
You can assign the extensions dynamically as for example in the code below:
string
[] allowedFileExtensions =
new
string
[3] {
"zip"
,
"doc"
,
"config"
};
RadAsyncUpload1.AllowedFileExtensions = allowedFileExtensions;
Hope this will help you solve the issue.
Regards,
Plamen
Telerik

Thanks for your response Plamen.....
I have used the following java script function to full fill requirement.
http://demos.telerik.com/aspnet-ajax/asyncupload/examples/validation/defaultcs.aspx

string[] allowedFileExtensions = new string[3] {"zip", "doc", "config"};
RadAsyncUpload1.AllowedFileExtensions = allowedFileExtensions;
You can set it at the beginning so Page_Load event may be suitable for this configuration.
Regards,
Plamen
Telerik

Thanks for response,
Please provide me sample for your response.
Actually ,My requirement goes like this , we dont have allowed list extensions (i mean we allowing all extensions except some which are in xml file ) , instead we have blocked list of file types/extensions. So i wrote java script which will check against the blocked list. should be removed from the upload file collection. So i wrote following java script.
function OnClientFileSelected(sender, args)
{
var currentFileName = args.get_fileName();
var fileExt = '.' + currentFileName.split('.').pop().toUpperCase();
if (!(IsValidFileType(fileExt))) {
// invalid file - inform user and remove
alert('"' + currentFileName + '" cannot be uploaded and will be removed.');
sender.deleteFileInputAt(args.get_rowIndex());
sender.deleteFileInputAt(currentFileName);
}
function IsValidFileType(fileext) {
var request = new XMLHttpRequest();
request.open("GET", "InvalidFileExtensions.xml", false);
request.send();
var xml = request.responseXML;
var fileTypes = xml.getElementsByTagName("InvalidFileExtensionList");
for (var i = 0; i < fileTypes.length; i++) {
var names = fileTypes[i].getElementsByTagName("FileExtension");
for (var j = 0; j < names.length; j++) {
if (fileext == (names[j].childNodes[0].nodeValue)) {
return false;
}
}
return true;
}
}
this script is running fine. It is able to remove blocked file extensions from uploading (i.e. i mean in UI). But in target folder am able to see the blocked files. It means in Front end the blocked file types are removed from uploading list.but in backend it goes to target folder.
for this reason i trying to block from server side. suggest whether i should solve my problem by going with server side or client script.
In such case you can try using the onFileUploaded event and check if the file has a correct extensions and set the isValid property accordingly.
Hope this will help you solve the issue.
Regards,
Plamen
Telerik