Anyone have any ideas on how to post PDF and binary files on a server to another server via a HTTP POST? I've been searching the web and have found some examples, but I can't seem to get them to work properly. I'm using Dundas' free upload component on the receiving server. I suspect it's something in my binary->string conversion, as I'm receiving an error that the Upload was not finished correctly. Looking at the header shows me that the Content-Length is not correct, but I can't override that either. I'm not loyal to this exact code, so any suggestions/code sample would be greatly appreciated!
Thanks!
...
Dim objHttp As XMLHTTP30
...
strBody = "--" & conststrBoundary & vbCrLf & "Content-Disposition: form-data; name=""FileName""" & vbCrLf & vbCrLf & strFileName & vbCrLf
strBody = strBody & "--" & conststrBoundary & vbCrLf & "Content-Disposition: form-data; name=""File1""; filename=""" & strFileName & """" & vbCrLf
strBody = strBody & "Content-Type: application/upload" & vbCrLf & vbCrLf
lngIndex = FreeFile
Open strFileName For Binary As lngIndex
ReDim aryBody(objFSO.GetFile(strFileName).Size - 1)
Get lngIndex, 1, aryBody
Close lngIndex
strBody = strBody & StrConv(aryBody, vbUnicode)
strBody = strBody & vbCrLf & "--" & conststrBoundary & "--"
objHttp.send strBody
Thanks!
...
Dim objHttp As XMLHTTP30
...
strBody = "--" & conststrBoundary & vbCrLf & "Content-Disposition: form-data; name=""FileName""" & vbCrLf & vbCrLf & strFileName & vbCrLf
strBody = strBody & "--" & conststrBoundary & vbCrLf & "Content-Disposition: form-data; name=""File1""; filename=""" & strFileName & """" & vbCrLf
strBody = strBody & "Content-Type: application/upload" & vbCrLf & vbCrLf
lngIndex = FreeFile
Open strFileName For Binary As lngIndex
ReDim aryBody(objFSO.GetFile(strFileName).Size - 1)
Get lngIndex, 1, aryBody
Close lngIndex
strBody = strBody & StrConv(aryBody, vbUnicode)
strBody = strBody & vbCrLf & "--" & conststrBoundary & "--"
objHttp.send strBody