getting file modified date from CuteWebUI_AjaxUploader_OnSelect

Last post 05-29-2011, 9:03 PM by Kenneth. 2 replies.
Sort Posts: Previous Next
  •  05-28-2011, 12:19 PM 67706

    getting file modified date from CuteWebUI_AjaxUploader_OnSelect

    Hi All
     
    im using the Ajaxuploader in my asp.net project
     
    im trying to get the uploaded files last modified date by using the Javascript  CuteWebUI_AjaxUploader_OnSelect Method
    there is a file array that i have access to
    eg

    var name=files[0].FileName;

    var size=files[0].FileSize // (or -1)

    is there a property in this that i can access to get the last modified date ?

     
    OR
     
    if this cant be done can i get the full file path that the user has selected so i can get the file modifed date another way
     
    Cheers
    Roughan
     
  •  05-28-2011, 12:52 PM 67707 in reply to 67706

    Re: getting file modified date from CuteWebUI_AjaxUploader_OnSelect

    in the

    hidden.internalobject

    there is a property called filePath
     
    can i access this for the original full file path ?
     
    im trying at the moment but i get a null

    alert (hidden.internalobject.filePath);

     
  •  05-29-2011, 9:03 PM 67714 in reply to 67707

    Re: getting file modified date from CuteWebUI_AjaxUploader_OnSelect

    Hi Roughan,
     
    Please try the example below. It shows you how to get the original file path.
     
    <%@ 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;
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            Uploader1.FileUploaded += new UploaderEventHandler(Uploader_FileUploaded);
            ButtonPostBack.Click += new EventHandler(ButtonPostBack_Click);
        }

        void ButtonPostBack_Click(object sender, EventArgs e)
        {
            InsertMsg("You clicked a PostBack Button.");
        }

        void SubmitButton_Click(object sender, EventArgs e)
        {
            InsertMsg("You clicked the Submit Button.");
            InsertMsg("You have uploaded " + uploadcount + " files.");
        }

        int uploadcount = 0;

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

            Uploader uploader = (Uploader)sender;
            //TextBox1.Text = args.
            InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");

            //Copys the uploaded file to a new location.
            //args.CopyTo(path);
            //You can also open the uploaded file's data stream.
            //System.IO.Stream data = args.OpenStream();
        }

        protected override void OnPreRender(EventArgs e)
        {
            SubmitButton.Attributes["hasfile"] = Uploader1.File == null ? "false" : "true";
            
            base.OnPreRender(e);
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <h2>
                    ManualStartUpload</h2>
                <asp:TextBox ID="TextBox1" runat="server" Width="240px"></asp:TextBox><CuteWebUI:UploadPersistedFile ItemTextTemplate="" runat="server" UploadType="IFrame"
                    ManualStartUpload="true" ID="Uploader1" InsertText="Upload File">
                </CuteWebUI:UploadPersistedFile>
                <br />
                <br />
                <asp:Button runat="server" ID="SubmitButton" OnClientClick="return submitbutton_click()"
                    Text="Submit" OnClick="SubmitButton_Click" />
                <br />
                <br />
                <div>
                    Server Trace:
                    <%=DateTime.Now.ToUniversalTime().Ticks %>
                    <br />
                    <asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
                </div>
                <br />
                <br />
                <asp:Button ID="ButtonPostBack" Text="This is a PostBack button" runat="server" />
            </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
                {
                    if(submitbutton.getAttribute("hasfile")=="true")
                    {
                        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;
        }
        function CuteWebUI_AjaxUploader_OnQueueUI(list)
        {
            var tb=document.getElementById('<%=TextBox1.ClientID %>');
            if(list.length==0)
            {
                tb.value="";
            }
            if(list.length==1)
            {
                //tb.value=list[0].FileName
                
                //IFrame mode:
                var uploadobj=document.getElementById('<%=Uploader1.ClientID %>');
                var tasks=uploadobj.internalobject.tasks;
                for(var p in tasks)
                {
                    var task=tasks[p];
                    if(task&&task.uploadid)
                    {
                        tb.value=task.file1.value;
                    }
                }
            }
            return false;
        }
            </script>

        </form>
    </body>
    </html>
     
    Regards,
     
    ken
     
View as RSS news feed in XML