Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello ,

I'm getting following error " Object reference not set to an instance of an object".
This s the code im using ..could not find image in folder .. ..How to Solve this?

C#
protected void Radbtn_Upload_Click(object sender, EventArgs e)
       {

           string filename = System.IO.Path.GetFileName( FileUpload.PostedFile.FileName);
           FileUpload.SaveAs(Server.MapPath("images/") + filename);

       }




thank you
Posted
Updated 14-May-15 19:53pm
v5
Comments
CHill60 14-May-15 4:20am    
Use your debugger and check the contents of FileUpload - if it is not null then check the content of FileUpload.PostedFile. Ensure that the object is initialised before the button can be pressed
Member 11148509 14-May-15 4:33am    
ya i have done debugging and as u said postedfile is showing null ...
_Asif_ 14-May-15 4:22am    
Why can't you debug your code and see the object which turns to be null?
Member 11148509 14-May-15 4:33am    
i have already done that was not getting so thought to post here
F-ES Sitecore 14-May-15 4:25am    
I'm going to take a punt that your fileupload is inside an UpdatePanel. If so, asp:FileUpload doesn't work inside an UpdatePanel, you need to use something specifically for asynch uploads.

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