Display alret when user tries upload file/s with a same name that already exist in DB

Last post 01-28-2013, 12:01 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  01-26-2013, 7:22 AM 76740

    Display alret when user tries upload file/s with a same name that already exist in DB

    .I am using Ajax Uploader in my .net project, which is allowing user to upload multiple file at a same time.

    While uploading new file/s, I want to display a pop up to a user if he/she is trying to upload a file which is already exist in database.(i.e. file with same name ).

    If user says Yes then it should continue uploading file (Which will ultimatly overwrite in DB)
    but if user says No then, how to cancel the upload for that specific file.

    I want to achive this from client side.
  •  01-28-2013, 12:01 PM 76743 in reply to 76740

    Re: Display alret when user tries upload file/s with a same name that already exist in DB

    Hi,

     

    Please try the example below, you can achieve it in "function myqueueuihandler(list)".

     

    1. <%@ Page Language="C#" Title="Customize the queue UI" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">  
    5.   
    6. <html xmlns="http://www.w3.org/1999/xhtml">  
    7. <head id="Head1" runat="server">  
    8. </head>  
    9. <body>  
    10.     <form id="Form1" runat="server">  
    11.         <CuteWebUI:Uploader ID="Uploader1" runat="server" MultipleFilesUpload="true">  
    12.         </CuteWebUI:Uploader>  
    13.     </form>  
    14. </body>  
    15.   
    16. <script>  
    17.   
    18. var uploader=document.getElementById("<%=Uploader1.ClientID %>");  
    19.   
    20. uploader.handlequeueui=myqueueuihandler;  
    21.   
    22. function myqueueuihandler(list)  
    23.   
    24. {  
    25.    for(var i=0;i<list.length;i++)  
    26.        {  
    27.           var name=list[i].FileName  
    28.           //you can check the file name here, if the file already exists '  list[i].Cancel();' will cancel this file  
    29.         
    30.               if(name=="1.gif")  
    31.            //Your code may be 'if(Service1.IsFileAlreadyUploaded(name));'  
    32.              {  
    33.               list[i].Cancel();  
    34.               }  
    35.         }  
    36.  }  
    37. </script>  
    38.   
    39. </html>  

    Regards,

     

    Ken 

View as RSS news feed in XML