W
Wayne Wengert
I am getting the following error whe I run this upload process. Code is
below - error points to the
lblInfo.Text = "Failed uploading file"
line? The upload runs fine and the file is properly uploaded to the
"scores" directory? What is it complaining about?
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
=================== code =======================
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
If Not (uploadedfile.PostedFile Is Nothing) Then
Try
Dim postedFile = uploadedfile.PostedFile
filename = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength
uploadedfile.PostedFile.SaveAs(Server.MapPath("./scores/" & filename))
'postedFile.SaveAs("./scores/" & filename)
lblInfo.Text = "Upload Successful!"
lblInfo.Visible = True
btnSave.Visible = True
Catch ex As Exception
lblInfo.Text = "Failed uploading file"
lblInfo.Visible = True
End Try
End If
End Sub
below - error points to the
lblInfo.Text = "Failed uploading file"
line? The upload runs fine and the file is properly uploaded to the
"scores" directory? What is it complaining about?
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
=================== code =======================
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnUpload.Click
If Not (uploadedfile.PostedFile Is Nothing) Then
Try
Dim postedFile = uploadedfile.PostedFile
filename = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength
uploadedfile.PostedFile.SaveAs(Server.MapPath("./scores/" & filename))
'postedFile.SaveAs("./scores/" & filename)
lblInfo.Text = "Upload Successful!"
lblInfo.Visible = True
btnSave.Visible = True
Catch ex As Exception
lblInfo.Text = "Failed uploading file"
lblInfo.Visible = True
End Try
End If
End Sub