InetHttpSendBitmap example for Visual Basic

1.

Start with a copy of the project that you created in InetHttpSendForm example for Visual Basic

2.

Add a command button to your form and name it as follows:

 

Name

Caption

 

SendBMP

Send Bitmap

3.

Code the SendBMP button's click procedure as follows:

Private Sub SendBMP_Click()
   Dim nRet As Integer
   nRet = HTTPObj.InetHttpConnect ("demo.leadtools.com", 80, "", "")
   If nRet = 0 Then
      nRet = HTTPObj.InetHttpOpenRequest (HTTP_RQST_GET, "/com/tutorial/http/upload.asp ", "", "HTTP/1.0")
      If nRet = 0 Then
         Dim strResponse As String
         Dim nv As NAMEVALUEItem
         Set nv = CreateObject("NAMEVALUEItem.NAMEVALUEItem.121")
         nv.pszName = "Photo"
         nv.pszValue = "photo1.jpg"
         IOObj.Load RasterObj, "v:\images\eagle.cmp", 0, 1, 1
         nRet = HTTPObj.InetHttpSendBitmap(RasterObj, FILE_JFIF, 24, 200, "image/jpg", nv)
         If nRet <> 0 Then
            MsgBox "Error Sending Image", vbExclamation, "Error"
            HTTPObj.InetHttpCloseRequest
            HTTPObj.InetHttpDisconnect
            Exit Sub
         End If
         Dim nStatus As Long
         HTTPObj.InetHttpGetServerStatus nStatus
         If nStatus = HTTP_STATUS_OK Then
            strResponse = HTTPObj.InetHttpGetResponse ()
            Open "c:\output.htm" For Binary As #1
            Put #1, , strResponse
            Close #1
         Else
            MsgBox "Problem With Server", vbExclamation, "Error"
            strResponse = HTTPObj.InetHttpGetResponse
            Kill "c:\error.htm"
            Open "c:\error.htm" For Binary As #1
            Put #1, , strResponse
            Close #1
         End If
         HTTPObj.InetHttpCloseRequest
      End If
      HTTPObj.InetHttpDisconnect
   End If
End Sub

4.

Run your program to test it.