Rutger
Legacy Member
Kheb een asp.net projectje dat een foto moet uploaden naar een map. Ik werk gewoon met een input type="file" om foto op te halen.
<input type="file" id="foto">
maar elke keer als ik op de knop uploaden klik geeft hij een fout bij mijn applicatie : mijn code ziet er als volgt uit :
Private Sub Controle()
If blnCheck = True Then
Dim strUrlFoto As String
Dim objCn As New OleDb.OleDbConnection(connectionString)
objCn.Open()
Dim intLengte As Integer
Dim t As Integer
Dim blnKlaar As Boolean
strUrlFoto = Foto.Value
intLengte = Len(strUrlFoto)
blnKlaar = False
For t = intLengte To 1 Step -1
If Mid(strUrlFoto, t, 1) = "\" And blnKlaar = False Then
strIngekort = "Teamleden" & Mid(strUrlFoto, t, intLengte)
Try
Foto.PostedFile.SaveAs(Server.MapPath(strIngekort))
Catch
MsgBox("Foutmelding", MsgBoxStyle.Critical, "Er is een fout opgetreden bij het uploaden van de foto")
End Try
blnKlaar = True
End If
Nextf
Foutmelding :
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 88: strUrlFoto = Foto.Value
Weet iemand hoe ik dit oplos???
<input type="file" id="foto">
maar elke keer als ik op de knop uploaden klik geeft hij een fout bij mijn applicatie : mijn code ziet er als volgt uit :
Private Sub Controle()
If blnCheck = True Then
Dim strUrlFoto As String
Dim objCn As New OleDb.OleDbConnection(connectionString)
objCn.Open()
Dim intLengte As Integer
Dim t As Integer
Dim blnKlaar As Boolean
strUrlFoto = Foto.Value
intLengte = Len(strUrlFoto)
blnKlaar = False
For t = intLengte To 1 Step -1
If Mid(strUrlFoto, t, 1) = "\" And blnKlaar = False Then
strIngekort = "Teamleden" & Mid(strUrlFoto, t, intLengte)
Try
Foto.PostedFile.SaveAs(Server.MapPath(strIngekort))
Catch
MsgBox("Foutmelding", MsgBoxStyle.Critical, "Er is een fout opgetreden bij het uploaden van de foto")
End Try
blnKlaar = True
End If
Nextf
Foutmelding :
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 88: strUrlFoto = Foto.Value
Weet iemand hoe ik dit oplos???