Get the number of files selected for upload

Last post 11-04-2008, 7:35 AM by Epok. 2 replies.
Sort Posts: Previous Next
  •  11-04-2008, 5:55 AM 45366

    Get the number of files selected for upload

    Hello,
     
    How can I know how many files has the user selected for upload?
     
    I want to start the upload automatically after the user's selection,and do some treatment at the end of the upload of the LAST file
     
     
    Thanks in advance,
  •  11-04-2008, 7:24 AM 45369 in reply to 45366

    Re: Get the number of files selected for upload

    Hi Epok,
     
     
    Try this example:
     

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        int addedcount = 0;
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }
     
     protected void Attachments1_AttachmentAdded1(object sender, AttachmentItemEventArgs args)
        {
            addedcount++;
            InsertMsg(args.Item.FileName + " has been uploaded.");
         
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (addedcount > 0)
            {
                InsertMsg(addedcount + " files have been uploaded");
                //when all files upload complete will fire
                Response.Write("<script>BLOCKED SCRIPTalert('done')<" + '/' + "script>");
            }
        }

      
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <CuteWebUI:UploadAttachments InsertText="Upload Multiple files Now" runat="server"
                    ID="Attachments1" OnAttachmentAdded="Attachments1_AttachmentAdded1">
                </CuteWebUI:UploadAttachments>
                <br />
                <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
            </div>
        </form>
    </body>
    </html>

     
     
    Regards,
     
    Ken
  •  11-04-2008, 7:35 AM 45370 in reply to 45369

    Re: Get the number of files selected for upload

    It's working perfectly :-)
     
    Thanks a lot !
View as RSS news feed in XML