Results 1 to 4 of 4

Thread: http Request Unterbrechen wenn keine Antwort kommt

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    2

    http Request Unterbrechen wenn keine Antwort kommt

    Hallo!
    Ich verwende folgenden Code um ein POST Formular mit einer Datei abzuschicken.
    Es kann aber sein, dass die Seite nicht erreichbar ist bzw. ich kein Ergebnis erhalte.
    Daher wollte ich fragen, wie ich dies prüfen kann um dann den Vorgang abzubrechen.
    Vielen Dank für jede Antwort.

    HTML Code:
    Private Function pvPostFile_werte2(sUrl As String, sFilename As String, Optional ByVal bAsync As Boolean) As String
        Const STR_BOUNDARY  As String = "3fbd04f5-b1ed-4060-99b9-fca7ff59c113"
        Dim nFile           As Integer
        Dim baBuffer()      As Byte
        Dim sPostData       As String
         Dim initdisplay As Integer
        Dim pfad As String
        Dim response As String
    
        On Error GoTo err
        
        '--- read file
        nFile = FreeFile
        Open sFilename For Binary Access Read As nFile
        If LOF(nFile) > 0 Then
            ReDim baBuffer(0 To LOF(nFile) - 1) As Byte
            Get nFile, , baBuffer
            sPostData = StrConv(baBuffer, vbUnicode)
        End If
        Close nFile
       
         
        '--- prepare body
         sPostData = "--" & STR_BOUNDARY & vbCrLf & _
            "Content-Disposition: form-data; name=""file_input""; filename=""" & Mid$(sFilename, InStrRev(sFilename, "\") + 1) & """" & vbCrLf & _
            "Content-Type: application/octet-stream" & vbCrLf & vbCrLf & _
            sPostData & vbCrLf & _
            "--" & STR_BOUNDARY & "--"
            '--- post
            
        With CreateObject("Microsoft.XMLHTTP")
            .Open "POST", sUrl, bAsync
            .SetRequestHeader "Content-Type", "multipart/form-data; boundary=" & STR_BOUNDARY
            .Send pvToByteArray(sPostData)
            response = .responsetext
            
           
        End With
    
    End Function

  2. #2
    Fanatic Member
    Join Date
    Jun 2015
    Posts
    748

    Re: http Request Unterbrechen wenn keine Antwort kommt


  3. #3
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    4,122

    Re: http Request Unterbrechen wenn keine Antwort kommt

    Hey, I recognize this GUID used for the form boundary as I generated it 10 years ago :))

    Unfortunately cannot comprehend the question enough. Who wants some proof and for what?

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    2

    Re: http Request Unterbrechen wenn keine Antwort kommt

    Danke für den Hinweis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width