Re: Validate Sum of file size for multiple files

  •  06-22-2011, 9:53 PM

    Re: Validate Sum of file size for multiple files

    Hi FLJoe,
     
    Please try the example below
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    4.   
    5.   
    6. <html xmlns="http://www.w3.org/1999/xhtml">  
    7. <head runat="server">  
    8.     <title>Untitled Page</title>  
    9. </head>  
    10. <body>  
    11.     <form id="form1" runat="server">  
    12.         <CuteWebUI:UploadAttachments ID="uploader1" runat="server" >  
    13.         </CuteWebUI:UploadAttachments>  
    14.     </form>  
    15. </body>  
    16. </html>  
    17. <script>  
    18. function CuteWebUI_AjaxUploader_OnSelect(files)  
    19. {  
    20.     //unit is b  
    21.     var maxLimit=1000000;  
    22.     //1000000=1mb  
    23.     var sum=0;  
    24.     for(var i=0;i<files.length;i++)  
    25.     {  
    26.         sum=sum+files[i].FileSize;  
    27.     }  
    28.     if(sum>maxLimit)  
    29.     {  
    30.         alert("Exceeded the maximum upload size limit");  
    31.         return false;  
    32.     }  
    33. }  
    34. </script> 
    Regards,
     
    ken
View Complete Thread