Let's add the required fields to the form:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wrobot As New foxtrot.xray.WebRobot
wrobot.Base = "http://www.yousendit.com/"
wrobot.LoadPage("/")
'getting file upload form from page
Dim wform As foxtrot.xray.Form = wrobot.GetFormByName("tform")
wform.AddField("text", "rcpt")
wform.AddField("file", "fname")
wform.AddField("hidden", "rurl", "http://www.yousendit.com/transfer.php?action=status")
End Sub
Now we have the required fields to be able to post to the form,
so we are going to continue the upload process. But first, we shall add
a dialog to select the file to upload, and then we will read the file
into memory:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wrobot As New foxtrot.xray.WebRobot
wrobot.Base = "http://www.yousendit.com/"
wrobot.LoadPage("/")
'getting file upload form from page
Dim wform As foxtrot.xray.Form = wrobot.GetFormByName("tform")
wform.AddField("text", "rcpt")
wform.AddField("file", "fname")
wform.AddField("hidden", "rurl", "http://www.yousendit.com/transfer.php?action=status")
'creating an Open File Dialog to choose file to upload
Dim fopendialog As New System.Windows.Forms.OpenFileDialog
fopendialog.CheckFileExists = True
If fopendialog.ShowDialog() = DialogResult.OK Then
'open file for reading
Dim fstream As New System.IO.FileStream(fopendialog.FileName, IO.FileMode.Open)
Dim bytFile(fstream.Length - 1) As Byte 'temporary buffer to store contents of file
fstream.Read(bytFile, 0, fstream.Length) 'read in the file
'the contents of the file to be uploaded to the server
Dim mstream As New System.IO.MemoryStream(bytFile)
End If
End Sub
Comments