Library tutorials & articles
Interacting with the web using WebRobot v1.0
By Fernando Sanchez, published on 17 May 2006
Page 3 of 5
- Logging in to MySpace
- Uploading files to YouSendIt
- Uploading files to YouSendIt: Adding fields
- Uploading files to YouSendIt: Setting form values
- Uploading files to YouSendIt: Submitting the form
Uploading files to YouSendIt: Adding fields
With Mozilla Firefox's Page Info dialog (right click on the page,
then click Page Info), we can see the form fields that have been added
via JavaScript to the form "tform". Of interest to us right now are the
"rcpt" field, "fname" field, and "rurl" field.
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.LoadNow 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:
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
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
Related articles
Related discussion
-
How to write the category attribut in a class dynamically
by converter2009 (1 replies)
-
VB.NET: Hide and show table using radio buttons
by converter2009 (1 replies)
-
VB.Net Button Problem
by pysdex (0 replies)
-
Unable to access AxInterop.AcoPdflib.dll on 64 bit OS
by Shaila14041981 (0 replies)
-
Very Urgent regarding deleting the images from a folder
by Nanosteps (6 replies)
Related podcasts
-
xpert to Expert: Inside Concurrent Basic (CB)
"Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...
This is a Very Good Example.I thin its very usefull to me.
but the problem is when i try this this not work properly error occured at this line "Dim wrobot As New foxtrot.xray.WebRobot()"
it displayes "File or Assembly name System,or one of its dependancies was not found."
Please answer to me.
This thread is for discussions of Interacting with the web using WebRobot v1.0.