I used file upload control for uploading photo but its throwing error "object reference not set to an instance of an object" only in dnn 481,dnn 482 versions. I used same control in dnn 470 version there it works fine.
Please find the code below
I used btn as asp button control,fu as asp file upload control,img as asp image control
I am getting error in this line " contLength = fu.PostedFile.ContentLength" as object refererence not set to an instance of an object.
I am able to get file upload control's ID but I am not able to capturethe content of that upload control.
Pls give me a soln.
Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn.Click
Dim contLength As Integer
contLength = fu.PostedFile.ContentLength
Dim myData(contLength) As Byte
fu.PostedFile.InputStream.Read(myData, 0, contLength)
Dim strpath As String = "C:\Inetpub\wwwroot\iredver1.0\CompanyLogo"
Dim strfileName As String = Path.GetFileName(fu.PostedFile.FileName)
Dim strpth As String = ""
strpth = Path.Combine(strpath, strfileName)
fu.SaveAs(strpth)
img.ImageUrl = strpth
End Sub