RadAsyncupload - unable to clear the uploaded file in OnClientFileSelected

4 posts, 0 answers
  1. Praveen kumar
    Praveen kumar avatar
    11 posts
    Member since:
    Jun 2015

    Posted 20 Jul 2015 Link to this post

    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.

     

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    835 posts

    Posted 23 Jul 2015 Link to this post

    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
  3. Praveen kumar
    Praveen kumar avatar
    11 posts
    Member since:
    Jun 2015

    Posted 23 Jul 2015 in reply to Ivan Danchev Link to this post

    Thanks Ivan....my problem got resolved. Thanks for your support.
  4. Ivan Danchev
    Admin
    Ivan Danchev avatar
    835 posts

    Posted 24 Jul 2015 Link to this post

    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
Back to Top