Amigos tengo un code con el que envio un FORM usando HTTPrequest con el metodo POST sin problemas, lo que sucede es que ese FORM tiene para mandar 3 fotos y ahi es donde se me traba el paraguas el CODE que tengo hasta ahora es este..
Muchas gracias por cualquier ayuda
Código (vbnet) [Seleccionar]
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim precio As String, categoria As String, titulo As String, cuerpo As String, _
filesize As String, email As String, phone As String
'Dim boundary As String = "---------------------------" + DateTime.Now.Ticks.ToString("x")
' Create the data we want to send
precio = "25"
categoria = "105"
titulo = "titulo del form"
cuerpo = "aki va el cuerpo del mensaje"
email = "user@gnome.com"
phone = "1234567"
filesize = "307200"
' Create a request using a URL that can receive a post.
Dim request As HttpWebRequest = HttpWebRequest.Create("URL")
' Set the Method property of the request to POST.
request.Method = "POST"
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
Dim postdata As String = "ad_price=" & precio & "&category=" & categoria & "&ad_headline=" & _
titulo & "&ad_text=" & cuerpo & "&email=" & email & "&phone=" & phone & "&MAX_FILE_SIZE=" & filesize
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postdata)
' Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded"
' Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length
' Get the request stream.
Dim dataStream As Stream = request.GetRequestStream()
' Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length)
' Close the Stream object.
dataStream.Close()
' Get the response.
Dim response As WebResponse = request.GetResponse()
' Display the status.
Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
' Get the stream containing content returned by the server.
dataStream = response.GetResponseStream()
' Open the stream using a StreamReader for easy access.
Dim reader As New StreamReader(dataStream)
' Read the content.
Dim responseFromServer As String = reader.ReadToEnd()
' Display the content.
txtoutput.Text = responseFromServer
' Clean up the streams.
reader.Close()
dataStream.Close()
response.Close()
End Sub
End Class
Muchas gracias por cualquier ayuda