下面是vb中的代码,发送数据流,那么远程upload.asp怎样写才能接收数据流呀?高手进啊! Dim req As System.Net.HttpWebRequest = _ CType(System.Net.WebRequest.Create(url), _ System.Net.HttpWebRequest) req.Method = "POST" req.ContentType = "multipart/form-data; boundary=" + boundary Dim postData As String = "" postData = "--" + boundary + vbCrLf + _ "Content-Disposition: form-data; name=""upfile""; filename=""" + _ fileName + """" + vbCrLf + _ "Content-Type: application/octet-stream" + vbCrLf + _ "Content-Transfer-Encoding: binary" + vbCrLf + vbCrLf Dim startData As Byte() = enc.GetBytes(postData) postData = vbCrLf + "--" + boundary + "--" + vbCrLf Dim endData As Byte() = enc.GetBytes(postData) Dim fs As New System.IO.FileStream( _ filePath, _ System.IO.FileMode.Open, _ System.IO.FileAccess.Read) req.ContentLength = startData.Length + endData.Length + fs.Length Dim reqStream As System.IO.Stream = req.GetRequestStream() reqStream.Write(startData, 0, startData.Length) Dim readData(&H1000) As Byte Dim readSize As Integer = 0 While True readSize = fs.Read(readData, 0, readData.Length) If readSize = 0 Then Exit While End If reqStream.Write(readData, 0, readSize) End While fs.Close() reqStream.Write(endData, 0, endData.Length) reqStream.Close() Dim res As System.Net.HttpWebResponse = _ CType(req.GetResponse(), System.Net.HttpWebResponse) Dim resStream As System.IO.Stream = res.GetResponseStream() Dim sr As New System.IO.StreamReader(resStream, enc) Console.WriteLine(sr.ReadToEnd()) sr.Close()
Dim req As System.Net.HttpWebRequest = _
CType(System.Net.WebRequest.Create(url), _
System.Net.HttpWebRequest)
req.Method = "POST"
req.ContentType = "multipart/form-data; boundary=" + boundary
Dim postData As String = ""
postData = "--" + boundary + vbCrLf + _
"Content-Disposition: form-data; name=""upfile""; filename=""" + _
fileName + """" + vbCrLf + _
"Content-Type: application/octet-stream" + vbCrLf + _
"Content-Transfer-Encoding: binary" + vbCrLf + vbCrLf
Dim startData As Byte() = enc.GetBytes(postData)
postData = vbCrLf + "--" + boundary + "--" + vbCrLf
Dim endData As Byte() = enc.GetBytes(postData) Dim fs As New System.IO.FileStream( _
filePath, _
System.IO.FileMode.Open, _
System.IO.FileAccess.Read) req.ContentLength = startData.Length + endData.Length + fs.Length
Dim reqStream As System.IO.Stream = req.GetRequestStream() reqStream.Write(startData, 0, startData.Length) Dim readData(&H1000) As Byte
Dim readSize As Integer = 0
While True
readSize = fs.Read(readData, 0, readData.Length)
If readSize = 0 Then
Exit While
End If
reqStream.Write(readData, 0, readSize)
End While
fs.Close()
reqStream.Write(endData, 0, endData.Length)
reqStream.Close()
Dim res As System.Net.HttpWebResponse = _
CType(req.GetResponse(), System.Net.HttpWebResponse)
Dim resStream As System.IO.Stream = res.GetResponseStream()
Dim sr As New System.IO.StreamReader(resStream, enc) Console.WriteLine(sr.ReadToEnd())
sr.Close()