locked
System.NullReferenceException: Object reference not set to an instance of an object. Upload Immage RRS feed

  • Question

  • User-1951273727 posted

    Hi i am getting the System.NullReferenceException: Object reference not set to an instance of an object. error when i try to upload an image can someone help? The site is going really well the only thing i can't seem to do is upload photo's.

    Protected Sub UploadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim newimageid As Integer
            newimageid = ImageUtils.uploadImage(Title.Text, CInt(AlbumList2.SelectedValue), FileUpload1.FileContent)
            ImageId = newimageid
            viewswitch.SetActiveView(main)
        End Sub


    It errors on newimageid = ImageUtils.uploadImage(Title.Text, CInt(AlbumList2.SelectedValue), FileUpload1.FileContent)

     

    please help this is driving me mad

     

    Tuesday, August 17, 2010 7:50 AM

All replies

  • User-1034726716 posted

    Hmm.. can you post your ASPX source here? I wan't to see how the control is declared on the page.


    Wednesday, August 18, 2010 1:55 AM
  • User-1254135497 posted

    hi.........

     u r not passing the file(image) which you uploaded.

    <strong>newimageid = ImageUtils.uploadImage(Title.Text, CInt(AlbumList2.SelectedValue), FileUpload1.FileContent)

    in this FileUpload1.FileContent is content of the file(image) which u uploaded but not the file.So,that u r geeting the error,try to pass file(image) insted of content like FileUpload1.PostedFile

    Thursday, August 19, 2010 12:34 AM
  • User-1951273727 posted

    Solved the problem i had not changed the connectin string over in one of the classes so when i compiled the site things like the image handler would not work properly as i had the wrong connection string. 

    Thursday, August 19, 2010 3:41 PM
  • User-2050792832 posted

    hi...i m having same problem in c#..

    Objectnullreference exception occured in following code.....

    please help......

    byte[] videoBytes = new byte[100];

    int fileLength7 = FileUpload2.PostedFile.ContentLength;
    videoBytes = new byte[fileLength7];
    FileUpload2.PostedFile.InputStream.Read(videoBytes, 0, fileLength7);

    Saturday, June 30, 2012 8:05 AM