multipart로 이미지 + 텍스트 파일 전송하는 부분인데
아에 기초도 모르고 있는 부분이어서 구글링 해서 코딩하긴 했는데
리턴값은 true로 나오는데 이미지가 제대로 올라가질 않은상태 입니다.
며칠째 고민하고 있는거라 사소한것이라도 도움이나 조언좀 부탁드립니다. file , Code 형태입니다.
아래는 코드 소스입니다.
Dim dataBoundary As String = "--xyz" Dim req As HttpWebRequest = DirectCast(WebRequest.Create("주소.xml"), HttpWebRequest) req.UserAgent = "Validator Test" req.ContentType = "multipart/form-data; boundary=xyz" req.Method = "POST" req.KeepAlive = True
Dim DataString As StringBuilder = New StringBuilder DataString.Append(dataBoundary + vbCrLf) DataString.Append("Content-Disposition: form-data; name=""file""; filename=""temp_image2.png""" + vbCrLf) DataString.Append("Content-Type: image/png" + vbCrLf) Dim localfile As String = Application.StartupPath & "\temp_image2.png" Dim BinaryData As Byte() = System.IO.File.ReadAllBytes(localfile) Dim FileData As String = Encoding.ASCII.GetString(BinaryData)
DataString.Append("--" + "xyz--" + vbCrLf) DataString.Append("Content-Disposition: form-data; Code=""00001""" + vbCrLf) DataString.Append("Content-Type: application/x-www-form-urlencoded" + vbCrLf) DataString.Append("xyz--") Dim Postdata As Byte() = Encoding.ASCII.GetBytes(DataString.ToString()) req.ContentLength = Postdata.Length Dim tempStream As Stream = req.GetRequestStream() tempStream.Write(Postdata, 0, Postdata.Length) tempStream.Close()
req.Method = "GET" Dim Resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse) Dim sr As StreamReader = New StreamReader(Resp.GetResponseStream(), Encoding.Default) 'Convert the stream to a string Dim s As String = sr.ReadToEnd() sr.Close() Resp.Close() MsgBox(s) |