Avoiding Multiple File Selection

2 posts, 0 answers
  1. Alp
    Alp avatar
    6 posts
    Member since:
    Oct 2008

    Posted 01 Aug 2013 Link to this post


    I am trying to avoid same file being selected more than one time. I have seen posts and replies such as
    but when multiple file is selected (not drag/drop but selection from file dialog) all those functions are failing. Mostly, they miss the duplicate item at index 0. I have tried many other ways but could not figure out a solid and reliable way to achieve this.

    Please note that I am also handling the file removed event and do some external stuff there, and I either need to find a way for one the scenarios below: 

    * catch and cancel duplicates when file is selected (before uploading etc.), in which case I do not need the file removed handler (since file was not actually selected, it was cancelled) 


    * catch duplicates at files uploaded event, and remove them from file list, properly calling file removed event

    When single file is selected, previously suggested functions work fine, but when 6-8 files selected, problems show up.

    Please advise.

  2. Hristo Valyavicharski
    Hristo Valyavicharski avatar
    975 posts

    Posted 06 Aug 2013 Link to this post

    Hi Alp,

    I would suggest you to perform file duplication check in OnClientFileUploading event:
    function OnClientFileUploading(sender, args) {
        var fileName = args.get_fileName();
        for (var i = 0; i < sender.getUploadedFiles().length; i++) {
            if (sender.getUploadedFiles()[i] === fileName) {
                console.log('duplicated' + fileName);
                $(".ErrorHolder").append(fileName + "duplicate file name have been remove automatically.<br/>").fadeIn("slow");

    <div class="ErrorHolder" style="background-color:red"></div>

    This validation should be working with both Single and Multiple files selection.

    Hristo Valyavicharski
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top