Getting File Duplicate Alert even if I have removed the file from upload

Last post 10-19-2011, 10:34 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  10-19-2011, 7:46 AM 70471

    Getting File Duplicate Alert even if I have removed the file from upload

    Hi,
     
     
    I am using following js while selecting files and when I remove one file from there and add the same file it is giving me alert that duplicate files. So can we remove the file from the array when we are removing the file from uploader??
     
     
        var uploadedFiles = [];
        function CuteWebUI_AjaxUploader_OnSelect(files) {
            var noDups = true;

            for (var i = 0; i < files.length; i++) {
                for (var j = 0; j < uploadedFiles.length; j++) {
                    if (files[i].FileName == uploadedFiles[j]) {
                        noDups = false;
                    }
                }
            }

            if (noDups) {
                for (var i = 0; i < files.length; i++) {
                    uploadedFiles.push(files[i].FileName);
                }
            }
            else {
                alert("Your last selection of files contains a duplicate filename, please try again");
            }
            return noDups;
        } 
     
     
    Thanks & regards,
    lbhatt
  •  10-19-2011, 10:34 AM 70474 in reply to 70471

    Re: Getting File Duplicate Alert even if I have removed the file from upload

    Hi lbhatt,
     
    Please try the example below
     
    <%@ Page Language="C#" Title="Customize the queue UI" %>

    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    </head>
    <body>
        <form id="Form1" runat="server">
            <CuteWebUI:UploadAttachments ID="uploader1" runat="server" ManualStartUpload="true">
            </CuteWebUI:UploadAttachments>
        </form>
    </body>

    <script>
     var uploadedFiles;
     function CuteWebUI_AjaxUploader_OnSelect(files)

    {
       for(var i=0;i<files.length;i++)
       {
            for(var j=0;j<uploadedFiles.length;j++)
            {
                if(files[i].FileName==uploadedFiles[j].FileName)
                {
                    alert("already has the same file");
                    return false;
                }
            }
       }
     }
    function CuteWebUI_AjaxUploader_OnQueueUI(list)
    {
       uploadedFiles=list;
    }
    </script>

    </html>
     
    Regards,
     
    Ken
View as RSS news feed in XML