0
我一直試圖使用多部分/表單數據發佈數據到服務器,但服務器似乎並沒有收到任何東西。爲什麼服務器沒有收到多部分/表單數據發佈數據
VB代碼
' 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
服務器接收到該請求,因爲它的數據發送回動的應用程序但它不識別張貼對
例如
$postedVal = isset($_POST["test1"]) ? $_POST["test1"] : '';
這會返回'',表示數據未被正確接收。
我沒有看到任何重大缺陷嗎?
任何建議將是偉大的。