Lost Session with upload file

  1. #1

    Lost Session with upload file

    Friend,
    I have a file upload object, but when I upload the file, the session variable is lost.
    Any suggestions?

    Thanks.
  2. #2

    RE: Lost Session with upload file

    Hi,

    please, give me more details and if possible put your codes.

    tnks
  3. #3

    RE: Lost Session with upload file

    the code

    .ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="wucUserForm.ascx.cs" Inherits="wucUserForm" %>
     <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
     <style type="text/css">
            .list-item {
                font:normal 11px tahoma, arial, helvetica, sans-serif;
                padding:3px 10px 3px 10px;
                border:1px solid #fff;
                border-bottom:1px solid #eeeeee;
                white-space:normal;
                color:#555;
            }
            
            .list-item h3 {
                display:block;
                font:inherit;
                font-weight:bold;
                color:#222;
            }
        </style>
         <style type="text/css">
            #fi-button-msg {
                border: 2px solid #ccc;
                padding: 5px 10px;
                background: #eee;
                margin: 5px;
                float: left;
            }
        </style>
    
        <script type="text/javascript">
            var showFile = function (fb, v) {
                var el = Ext.fly('fi-button-msg');
                el.update('Selected: ' + v);
                if (!el.isVisible()) {
                    el.slideIn('t', {
                        duration: .2,
                        easing: 'easeIn',
                        callback: function() {
                            el.highlight();
                        }
                    });
                } else {
                    el.highlight();
                }
            }            
        </script>
     <ext:Panel 
                ID="pnlMainUser" runat="server" 
                Frame="false" Border="false"
                Width="680px"  ButtonAlign="Right"
                Height="400px"
                BodyStyle="margin-left:100px;margin-top:20px;background-color: #EFEFEF;">
                <Body>
                <ext:Panel ID="pnlMainUserContainer" runat="server" 
                Frame="true" Border="false"
                Width="550px" ButtonAlign="Right" Height="400px">
                <Body>
                 <ext:TabPanel ID="tbpUser" runat="server" ActiveTabIndex="0" Frame="false" Border="false" Height="320">
                        <Tabs>
                                <Body>
                            <ext:Tab ID="tbPhoto" runat="server" Frame="true" Title="Photo" Icon="Image">
                                <Body>
                                    <ext:FormPanel ID="fpPhoto" runat="server" BodyStyle="padding:5px;" ButtonAlign="Right"
                                        Frame="false" Border="false" Height="270" Width="240" LabelSeparator="" LabelWidth="1">
                                        <Body>
                                            <ext:FormLayout ID="flPhoto" runat="server">
                                                <ext:Anchor>
                                                    <ext:Image ID="imgPhoto" runat="server" Height="160" Width="160">
                                                    </ext:Image>
                                                </ext:Anchor>
                                                   <ext:Anchor>    
                                                 <ext:MultiField ID="mfButtons" runat="server">
                                                    <Fields>
                                                     <ext:FileUploadField ID="fufImage" runat="server" ButtonOnly="true" StateID="IMG">
                                                        <Listeners>
                                                            <FileSelected Fn="showFile" />
                                                        </Listeners>
                                                    </ext:FileUploadField>
                                                    <ext:Button ID="bSave" runat="server" Text="Submit">
                                                    <AjaxEvents>
                                                    <Click OnEvent="UploadClick"></Click>
                                                    </AjaxEvents>
                                                    </ext:Button>
                                                    </Fields>
                                                </ext:MultiField>
                                                 </ext:Anchor>
                                                 <ext:Anchor>
                                                 <ext:Label ID="lMensaje"  runat="server"></ext:Label>
                                                 </ext:Anchor>
                                            </ext:FormLayout>
                                            <div id="fi-button-msg" style="display:none;">
    
                                                     <div class="x-clear">
    
                                        </Body>
                                       
                                    </ext:FormPanel>
                                </Body>
                            </ext:Tab>
                        </Tabs>
                    </ext:TabPanel>
                </Body>
                 <Buttons>
                <ext:Button ID="bSaveUser" runat="server" Icon="Disk" Text="Grabar">
                <AjaxEvents>
                <Click OnEvent="SaveData"></Click>
                </AjaxEvents>
                </ext:Button>
            </Buttons>
        </ext:Panel>
        </Body></ext:Panel>
    .ascx.cs
    using System;
    ...
    public partial class wucUserForm : System.Web.UI.UserControl
    {
        GCThunder.Library.Platform.Web.SessionInfo si = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            si = (GCThunder.Library.Platform.Web.SessionInfo)Session["mySession"];
    
            
        }
        protected void SaveData(object sender, EventArgs e)
        {
            //lMensaje.Text = fufImage.FileName + " : " + ss;
            this.fufImage.PostedFile.SaveAs("C:\\test123456.jpg");
        }
        protected void UploadClick(object sender, EventArgs e)
        {
            string tpl = "Uploaded file: {0}<br/>Size: {1} bytes";
            if (this.fufImage.HasFile)
            {
    
                Ext.Msg.Show(new MessageBox.Config
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.INFO,
                    Title = "Success",
                    Message = string.Format(tpl, this.fufImage.PostedFile.FileName, this.fufImage.PostedFile.ContentLength)
                });
            }
            else
            {
                Ext.Msg.Show(new MessageBox.Config
                {
                    Buttons = MessageBox.Button.OK,
                    Icon = MessageBox.Icon.ERROR,
                    Title = "Fail",
                    Message = "No file uploaded"
                });
            }
        }
    }

Similar Threads

  1. [CLOSED] multiple file upload and file size at client side
    By mirwais in forum 1.x Legacy Premium Help
    Replies: 24
    Last Post: Dec 15, 2014, 5:44 AM
  2. Session is lost when you use FileUploadField
    By xtremexploit in forum 1.x Help
    Replies: 4
    Last Post: Aug 23, 2011, 6:05 PM
  3. Replies: 1
    Last Post: Jun 23, 2011, 9:37 AM
  4. Upload file
    By Egale in forum 1.x Help
    Replies: 1
    Last Post: May 25, 2011, 10:08 AM
  5. [CLOSED] file upload - file name is empty
    By stoque in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 11, 2011, 8:06 PM

Posting Permissions