can we add extra information on the object that ajax uploader sends for each file?

Last post 01-19-2011, 10:39 AM by Eric. 3 replies.
Sort Posts: Previous Next
  •  01-18-2011, 11:35 AM 65772

    can we add extra information on the object that ajax uploader sends for each file?

       Hi! 
     
    can we add extra information on the ajaxuploader object thet we access in server events to get the file information...?
  •  01-18-2011, 3:17 PM 65775 in reply to 65772

    Re: can we add extra information on the object that ajax uploader sends for each file?

    Dear deepakkumarjoshi,
     
    Please refer to the following highlighted code:
     
    <%@ 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">  
       
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }
        void SubmitButton_Click(object sender, EventArgs e)
        {
            InsertMsg("You clicked the Submit Button.");
            InsertMsg("You have uploaded " + uploadcount + "/" + Uploader1.Items.Count + " files.");
        }

        int uploadcount = 0;

        void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            uploadcount++;

            Uploader uploader = (Uploader)sender;
            InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
            //Copys the uploaded file to a new location.
             args.CopyTo("c://temp"+args.FileName);
             System.IO.FileInfo fi = new System.IO.FileInfo("c://temp"+args.FileName);
             InsertMsg(fi.Extension);
             InsertMsg(fi.FullName);
             InsertMsg(fi.Name);
             InsertMsg(fi.CreationTime.ToString());
             InsertMsg(fi.LastAccessTime.ToString());
             InsertMsg(fi.LastWriteTime.ToString());
             InsertMsg(fi.DirectoryName);
            //You can also open the uploaded file's data stream.
            //System.IO.Stream data = args.OpenStream();
        }

        protected override void OnPreRender(EventArgs e)
        {
            SubmitButton.Attributes["itemcount"] = Uploader1.Items.Count.ToString();
            base.OnPreRender(e);
        }
     
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Start uploading manually</title>
        <link rel="stylesheet" href="demo.css" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
            <div class="content">
                <h2>
                    Start uploading manually</h2>
                <p>
                    This sample demonstrates how to start uploading manually after file selection vs
                    automatically.</p>
                <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1"
                    InsertText="Browse Files (Max 1M)" OnFileUploaded="Uploader_FileUploaded">
                    <ValidateOption MaxSizeKB="1024" />
                </CuteWebUI:UploadAttachments>
                <br />
                <br />
                <asp:Button runat="server" ID="SubmitButton" OnClientClick="return submitbutton_click()"
                    Text="Submit" OnClick="SubmitButton_Click" />
                <br />
                <br />
                <div>
                    <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
                </div>

                <script type="text/javascript">

                    function submitbutton_click() {
                        var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
                        var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');
                        if (!window.filesuploaded) {
                            if (uploadobj.getqueuecount() > 0) {
                                uploadobj.startupload();
                            }
                            else {
                                var uploadedcount = parseInt(submitbutton.getAttribute("itemcount")) || 0;
                                if (uploadedcount > 0) {
                                    return true;
                                }
                                alert("Please browse files for upload");
                            }
                            return false;
                        }
                        window.filesuploaded = false;
                        return true;
                    }
                    function CuteWebUI_AjaxUploader_OnPostback() {
                        window.filesuploaded = true;
                        var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
                        submitbutton.click();
                        return false;
                    }
                </script>

            </div>
        </form>
    </body>
    </html>

    Thank you for asking
  •  01-18-2011, 9:10 PM 65780 in reply to 65775

    Re: can we add extra information on the object that ajax uploader sends for each file?

    Hi! Thanks! for the reply, it was gud, but i want add the information  from the client(javscript) side to send to the server side while the files are uploading.
  •  01-19-2011, 10:39 AM 65798 in reply to 65780

    Re: can we add extra information on the object that ajax uploader sends for each file?

    Dear deepakkumarjoshi,
     
    Which information do you want to pass from client to server side while files are being uploaded?
     
    Thank you for asking
View as RSS news feed in XML