Quantcast
Channel: Microsoft Access Forum
Viewing all articles
Browse latest Browse all 880

Datei Upload WinHttpRequest.5.1

$
0
0

ich benutze folgende Function zum Datei Download

möchte jetzt aber gerne eine Datei Hochladen - geht das auch mit 

WinHttp.WinHttpRequest.5.1

oder stelle ich mir das zu einfach vor

Public Function DateidownloadADOStream(ByVal strDateiadresse As String, ByVal strZieladresse As String, MitFehlermeldung As Boolean) As Boolean
On Error GoTo Fehler

Dim oHttp, sURL, sSavePath, oStream
  
Set oHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
oHttp.Open "GET", strDateiadresse & "?a=" & Int((1000000 - 1 + 1) * Rnd + 1), False
oHttp.setRequestHeader "Cache-control", "no-cache"
oHttp.Send
If oHttp.Status = 200 Then
    Set oStream = CreateObject("adodb.stream")
    oStream.Type = 1 '1=adTypeBinary
    oStream.Open
    oStream.Write oHttp.responseBody
    oStream.SaveToFile strZieladresse, 2 '2=adSaveCreateOverWrite, 1=adSaveCreateNotExist
    Set oStream = Nothing
Else

End If

Set oHttp = Nothing
DateidownloadADOStream = True
Exit Function

Fehler:
DateidownloadADOStream = False
If MitFehlermeldung = True Then MsgBox Err.Number & vbCrLf & "Fehlerbeschreibung: " & Err.Description & vbCrLf & "Dateiname: " & strDateiadresse

End Function


Viewing all articles
Browse latest Browse all 880