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;
                Response.Write("<script language='javascript'> alert('No image uploaded'); </script>");

thanks !
Will come with additional questions.

Recommended Answers

All 4 Replies

>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.

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"];

>Is this correct?


if(Session["File"]!=null) {
  filebytes=(byte[]) Session["File"];

thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.