0

I have an asp FileUpload and an asp Button on a page. When i click the button, i want the bytes of the file which was supposedly uploaded to be stored in a session variable.
Only problem is that they aren't stored.
How should i do this?
There's also a text box with some text in it, need that too.

protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FUpload.HasFile)
            {
                Session["File"] = FUpload.FileBytes;
                Session["Name"] = FUpload.FileName;
                if (TextBoxEnc.Text != "")
                    Session["Text"] = TextBoxEnc.Text;
            }
            else
                Response.Write("<script language='javascript'> alert('No image uploaded'); </script>");
        }

thanks !
Will come with additional questions.

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by TotoTitus
0

>Only problem is that they aren't stored. How should i do this?

There is no problem at all. You have done already. Tell us what you're trying to do and we can tell you how to go about it.

0

I want to copy at a later time the contents of the session variable Session["File"] into a byte array, byte [] filebytes;
How do i do that?
Is this correct?

filebytes=(byte[]) Session["File"];
1

>Is this correct?

Yes.

if(Session["File"]!=null) {
  filebytes=(byte[]) Session["File"];
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.