How to set the file names in FileTooLargeMsg property?

Last post 02-06-2013, 12:08 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  02-05-2013, 12:03 PM 76799

    How to set the file names in FileTooLargeMsg property?

    Hi,

     

    how to set the FileTooLargeMsg property with a custom message to display large file names when we upload the multiple files through ajax uploader?

     

    we need to display the message something like below

    FileTooLargeMsg="{File1},{File2} cannot be uploaded. File size(File1:10MB,File2:20MB) is too large"

     

    <CuteWebUI:UploadAttachments runat="server" ID="Uploader1" MaxFilesLimit="5"  FileTooLargeMsg="File1,File2 cannot be uploaded. File size(File1:10MB,File2:20MB) is too large" MaxFilesLimitMsg="support 5 file a time">
            <ValidateOption MaxSizeKB="1000" />
    </CuteWebUI:UploadAttachments>

  •  02-05-2013, 1:08 PM 76801 in reply to 76799

    Re: How to set the file names in FileTooLargeMsg property?

    Hi mvjr,

     

    The catch error function will check the file one by one, so it will not get all the large files at the same time. you can catch all upload file size when the user selec the files for upload, then check it by your own code, like below.

     

     

    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>  
    4. <!DOCTYPE html>  
    5.   
    6.   
    7. <html xmlns="http://www.w3.org/1999/xhtml">  
    8. <head runat="server">  
    9.     <title></title>  
    10. </head>  
    11. <body>  
    12.     <form id="form1" runat="server">  
    13.                      <CuteWebUI:UploadAttachments runat="server" ID="uploader1">  
    14.                          </CuteWebUI:UploadAttachments>  
    15.     </form>  
    16. </body>  
    17. </html>  
    18. <script type="text/javascript">  
    19.     function CuteWebUI_AjaxUploader_OnSelect(files) {  
    20.         var namelist = "";  
    21.         var sizelist = "";  
    22.         for (var i = 0; i < files.length; i++)  
    23.         {  
    24.             var size = files[i].FileSize / 1024;//kb  
    25.             //max is 10kb  
    26.             if (size > 10)  
    27.             {  
    28.                 namelist+=files[i].FileName;  
    29.                 namelist += ",";  
    30.                 sizelist += size;  
    31.                 sizelist += ",";  
    32.             }  
    33.            
    34.         }  
    35.         if (namelist != "")  
    36.         {  
    37.             alert(namelist + "cannot be uploaded. File size(" + sizelist + ") is too large");  
    38.             return false;  
    39.         }  
    40.         
    41.     }  
    42. </script>  

    Regards,

     

    Ken 

  •  02-06-2013, 9:17 AM 76805 in reply to 76801

    Re: How to set the file names in FileTooLargeMsg property?

    Thanks Ken,

     

    i have a question regarding size check( if (size > 10)). how to read the ajax uploader control "MaxsizeKB" property to verify the size(i.e, if size >  "MaxsizeKB") in the "CuteWebUI_AjaxUploader_OnSelect" function?

     

  •  02-06-2013, 12:08 PM 76807 in reply to 76805

    Re: How to set the file names in FileTooLargeMsg property?

    Hi mvjr,

     

    You can get it by the code below, uploader1 is the uploader control id.

     

    1. <script type="text/javascript">  
    2.     function CuteWebUI_AjaxUploader_OnSelect(files) {  
    3.         var maxSizeKB = "<%= uploader1.ValidateOption.MaxSizeKB %>";  
    4.     }  
    5. </script>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML