Hello.
Im doing program that automatically uploads images/file to web server using post data.
So far ive figured out code that sends text. Now next step is to send that file instead of text and thats where I need your help.
HTML form that does the job for me is:
And vb.net code that sends text and returns what ever my php code generates is:
I hope some of you can help me to upgrade this code to send file
Im doing program that automatically uploads images/file to web server using post data.
So far ive figured out code that sends text. Now next step is to send that file instead of text and thats where I need your help.
HTML form that does the job for me is:
VB.NET:
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input name="uploadedfile" type="file">
<input type="submit" value="Send">
</form>
And vb.net code that sends text and returns what ever my php code generates is:
VB.NET:
Imports System.IO
Imports System.Net
Imports System.Web
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim errorString As String = "Any String"
Dim request As WebRequest = WebRequest.Create("http://myurl.com/uploader.php")
request.Method = "POST"
Dim postData = "g=" & errorString
Dim byteArray As Byte() = System.Text.Encoding.UTF8.GetBytes(postData)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim response As WebResponse = request.GetResponse()
dataStream = response.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
response.Close()
TextBox1.Text = responseFromServer
End Sub
End Class
I hope some of you can help me to upgrade this code to send file