Upload photos should not upload any file with 0 bytes or show a proper warning message

Last post 04-28-2009, 12:04 AM by Shaitender. 2 replies.
Sort Posts: Previous Next
  •  04-21-2009, 11:47 PM 51344

    Upload photos should not upload any file with 0 bytes or show a proper warning message

    Hello guys
     
    i wanted to restrict user to Upload photos should not upload any file with 0 bytes or show a proper warning message
     
    Can you tell me how can i restrict that ...Help needed urgently !!!
     
    Thanks
     
  •  04-23-2009, 9:16 AM 51430 in reply to 51344

    Re: Upload photos should not upload any file with 0 bytes or show a proper warning message

    Hi,
     
    Here is an example for you :
     
     
    1. <%@ Page Language="C#" Title="First sample" %>  
    2. <%@ Import Namespace="CuteWebUI" %>  
    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. <script runat="server">  
    7.   
    8.     void InsertMsg(string msg)   
    9.     {   
    10.         ListBoxEvents.Items.Insert(0, msg);   
    11.         ListBoxEvents.SelectedIndex = 0;   
    12.     }   
    13.     protected void UploadAttachments1_AttachmentAdded(object sender, AttachmentItemEventArgs args)   
    14.     {   
    15.         InsertMsg("Added.." + args.Item.FileName);   
    16.     }   
    17.   
    18.     protected void UploadAttachments1_FileValidating(object sender, UploaderEventArgs args)   
    19.     {   
    20.         if (args.FileSize == 0)   
    21.         {   
    22.             throw (new Exception("Please do not upload empty file !"));   
    23.         }   
    24.     }   
    25. </script>  
    26.   
    27. <html xmlns="http://www.w3.org/1999/xhtml">  
    28. <head id="Head1" runat="server">  
    29. </head>  
    30. <body>  
    31.     <form id="Form1" runat="server">  
    32.         <CuteWebUI:UploadAttachments runat="server" ID="UploadAttachments1"    
    33.             OnAttachmentAdded="UploadAttachments1_AttachmentAdded"    
    34.             OnFileValidating="UploadAttachments1_FileValidating">  
    35.         </CuteWebUI:UploadAttachments>  
    36.         <br />  
    37.         <div>  
    38.             Server Trace:   
    39.             <br />  
    40.             <asp:ListBox runat="server" ID="ListBoxEvents" Width="800"></asp:ListBox>  
    41.         </div>  
    42.     </form>  
    43. </body>  
    44. </html>  
    Regards,
    Terry
  •  04-28-2009, 12:04 AM 51586 in reply to 51430

    Re: Upload photos should not upload any file with 0 bytes or show a proper warning message

    THanks ..Terry !!!
     
    Thanks a lot !!!
View as RSS news feed in XML