This is a migrated thread and some comments may be shown as answers.

RadAsyncupload - unable to clear the uploaded file in OnClientFileSelected

3 Answers 46 Views
Miscellaneous
This is a migrated thread and some comments may be shown as answers.
Praveen kumar
Top achievements
Rank 1
Praveen kumar asked on 20 Jul 2015, 08:17 PM

Hi All,

My requirement goes like , we dont have allowed list extensions , instead we have blocked list of file types/extensions. So i wrote java script which will check against the blocked list [i.e xml file]. 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);
               }
           }

this script is runing fine. It is able to remove blocked file extensions from uploading. 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.

 

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 23 Jul 2015, 03:13 PM
Hello,

The RadAsyncUpload's OnClientFileSelected event cannot be canceled so in addition to the code in its event handler you should also subscribe to the OnClientFileUploading event and cancel it if the user tries to upload a file with extension present in the blocked extensions list:
function OnClientFileUploading(sender, args) {
 
    var currentFileName = args.get_fileName();
    var fileExt = '.' + currentFileName.split('.').pop().toUpperCase();
    if (!(IsValidFileType(fileExt))) {
        args.set_cancel(true);
    }
}

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Praveen kumar
Top achievements
Rank 1
answered on 23 Jul 2015, 03:53 PM
Thanks Ivan....my problem got resolved. Thanks for your support.
0
Ivan Danchev
Telerik team
answered on 24 Jul 2015, 07:13 AM
Hello,

You are welcome. I am glad the uploaded file type validation is working as expected.

Regards,
Ivan Danchev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Miscellaneous
Asked by
Praveen kumar
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Praveen kumar
Top achievements
Rank 1
Share this question
or