|
[code=vb] Private Sub SetUpData(objhttpItem As HttpItem)
'httpWebRequest__1.ContentType = "multipart/form-data; boundary=" & boundary
'UpDate_boundary
'UpDate_Type
'UpDate_FileName
Dim boundary As String = objhttpItem.UpDate_boundary
Dim boundarybytes As Byte() = System.Text.Encoding.ASCII.GetBytes(vbCr & vbLf & "--" & boundary & vbCr & vbLf)
request.GetRequestStream().Write(boundarybytes, 0, boundarybytes.Length)
Dim headerTemplate As String = "Content-Disposition: form-data; name=""{0}""; filename=""{1}""" & vbCr & vbLf & "Content-Type: {2}" & vbCr & vbLf & vbCr & vbLf
Dim header As String = String.Format(headerTemplate, objhttpItem.UpDate_name, objhttpItem.UpDate_FileName, objhttpItem.UpDate_Type)
Dim headerbytes As Byte() = System.Text.Encoding.UTF8.GetBytes(header)
request.GetRequestStream().Write(headerbytes, 0, headerbytes.Length)
'HttpContext.Current.Response.Write(IO.Path.GetFileName(GetUrl))
'HttpContext.Current.Response.Write(GetContentType(IO.Path.GetFileName(GetUrl)))
Dim buffer As Byte() = New Byte(4095) {}
Dim byteSeq As Integer = objhttpItem.UpDate_Stream.Read(buffer, 0, 4096)
Do While byteSeq > 0
request.GetRequestStream().Write(buffer, 0, byteSeq)
byteSeq = objhttpItem.UpDate_Stream.Read(buffer, 0, 4096)
Loop
Dim trailer As Byte() = System.Text.Encoding.ASCII.GetBytes(vbCr & vbLf & "--" & boundary & "--" & vbCr & vbLf)
request.GetRequestStream().Write(trailer, 0, trailer.Length)
request.GetRequestStream().Close()
End Sub[/code]
|
|