I've been trying to post data to a server using multipart/form-data however the server doesn't seem to receieve anything.
VB Code
' create a boundary consisting of a random string
strBoundary = RandomAlphaNumString(32)
strBody = "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""test1""" & vbCrLf & vbCrLf & STRING
strBody = strBody & vbCrLf & "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""data""" & vbCrLf & vbCrLf & data
strBody = strBody & vbCrLf & "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""data2""" & vbCrLf & vbCrLf & data2
strBody = strBody & vbCrLf & "--" & strBoundary & vbCrLf
strBody = strBody & "Content-Disposition: form-data; name=""data3""" & vbCrLf & vbCrLf & data3
strBody = strBody & vbCrLf & "--" & strBoundary & "--"
' Content-Length
sHttpLength = Len(strBody)
Set WinHttpReq = New WinHttpRequest
strURL = "https://" & HOST & URL ' directed to test.php
hostHeader = HOST & vbCrLf
contentTypeHeader = "multipart/form-data; boundary=" & strBoundary & vbCrLf
contentLengthHeader = sHttpLength & vbCrLf & vbCrLf
WinHttpReq.Open "POST", strURL, False 'Open a Http connection
WinHttpReq.SetRequestHeader "HOST", hostHeader
WinHttpReq.SetRequestHeader "Content-Type", contentTypeHeader
WinHttpReq.SetRequestHeader "Content-Length", contentLengthHeader
WinHttpReq.Send strBody ' Send Post messages
The server is receiving the request as it sends back data to the vb app however it doesn't recognise the posted pairs
e.g.
$postedVal = isset($_POST["test1"]) ? $_POST["test1"] : '';
This returns '' showing that the data hasn't been received correctly.
Is there any major flaw I'm not seeing?
Any advice would be great.