Limit total size of attachments

Last post 01-31-2011, 3:04 PM by Eric. 1 replies.
Sort Posts: Previous Next
  •  01-27-2011, 3:35 PM 65921

    Limit total size of attachments

    How it is possible to limit total size of attachments. For example, total size 5Mb, max file size 5Mb, but we can load 2 or more files with length less 5Mb
    Filed under:
  •  01-31-2011, 3:04 PM 65971 in reply to 65921

    Re: Limit total size of attachments

    Dear SergeyC,
     
    Client validation:
    <script type="text/javascript">
    function CuteWebUI_AjaxUploader_OnSelect(files) {
                var selectedSize = 0;
                for (var i = 0; i < files.length; i++) {
                    selectedSize += files[i].FileSize;
                }
                //if selected files size is greater than this value, will stop the upload
                if (selectedSize > 1024 * 1024 * 1024) {
                       alert("the selected file size is "+ FormatSize(selectedSize)+",you only can upload 1G files");
                       return false;
                }
            }
    </script>
     
    Server side validation:
         void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
              //validate the total size of uploaded files or validate the used space of destination folder    
        }   
     
    Thank you for asking
View as RSS news feed in XML