Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi guys,

I was using fileupload but whenever i click on save button,
this fileupload getting null...

even though i tried using sessions as well, but still its same,

my code:

Byte[] img = null;
            Session["image"] = EmpImg;

            if (Session["image"] != null)
            {
                FileUpload FUEMP = (FileUpload)Session["image"];
                if (FUEMP.HasFile && FUEMP.PostedFile != null)
                {
                    HttpPostedFile Myfile = FUEMP.PostedFile;
                    img = new Byte[Myfile.ContentLength];
                    Myfile.InputStream.Read(img, 0, Myfile.ContentLength);
                }
            }


can anyone plzzzz... help me....

thanks
Posted
Updated 3-May-14 21:48pm
v3
Comments
karthik Udhayakumar 3-May-14 15:12pm    
Why you wanna go for session for Fileupload?.pls dispatch the entire code or debug let know which displays null:)
abdul subhan mohammed 4-May-14 2:54am    
bcoz, the fileupload getting null on button click, that's y, i'm using sessions.
[no name] 4-May-14 4:52am    
Probably because Session["image"] is not a FileUpload. Try using FindControl.
ZurdoDev 4-May-14 7:57am    
See http://asp.net-tutorials.com/controls/file-upload-control/
Jignesh Khant 5-May-14 0:52am    
Do you have autopostback for any control? Because of autopostback your selected file may get cleared & you might get null value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900