Duplicate file checking while adding the attachment in RadAsyncUpload

2 posts, 0 answers
  1. Mohinder Goswami
    Mohinder Goswami avatar
    24 posts
    Member since:
    Nov 2008

    Posted 05 Oct 2013 Link to this post

    Hi All,

    I am using the RadAsyncUpload in my app. So what I need as follows whenever we select any attachment to upload how to add the duplicate file checking from the client side, and that to while picking the attachments itself.


    Anybody knows how to do this?.



  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2013 Link to this post

    Hi Mohinder Goswami,

    It is not possible to access the uploaded files while attaching a file in RadAsyncUpload. So one suggestion is you can access the already uploaded file names on server side and keep it in a hidden field and OnClientFileSelected event you can check the duplication using that hidden field as follows.

    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" OnClientFileSelected="OnClientFilesSelected1"
        MultipleFileSelection="Automatic" TargetFolder="~/Uploads">
    <asp:HiddenField ID="hiddenfield1" runat="server" />

    <script type="text/javascript">
        function OnClientFilesSelected1(sender, args) {
            var hiddenfield1=document.getElementById("<%= hiddenfield1.ClientID %>");
            var filenames = hiddenfield1.value;
            var currentfiles = args.get_fileName();
            var filename = filenames.split(",");
            for (var i = 0; i < filename.length; i++) {
                if (filename[i] == currentfiles) {
                    alert("Duplicate File");

    string str=string.Empty;
    protected void Page_Load(object sender, EventArgs e)
        string path = Server.MapPath(RadAsyncUpload1.TargetFolder);
        DirectoryInfo d = new DirectoryInfo(path);
        FileInfo[] Files = d.GetFiles();
        foreach (FileInfo file in Files)
            str += file.Name + ",";
         hiddenfield1.Value = str;

Back to Top