Any easy code samples for uploading web pages to a server using VB out there?
Printable View
Any easy code samples for uploading web pages to a server using VB out there?
use the Inet control, set its protocol to ftp, give a host name, user name and password and use ftp commands to put the files.
use the inet_statechanged method to find out when its finished.
hope this helps
I'm not very familiar with ftp code at all. Would you have a code sample?
create a command then execute it.
VB Code:
command = "put c:\data\myImage.jpg /users/me/myImage.jpg" Call Inet1.Execute(, command)
Then to check that it has finished - Inet ftp commands do not halt the flow of the program - i.e. the next line executes before you get a result.
VB Code:
Select Case State Case icResolvingHost 'txtStatus.Text = txtStatus.Text & "Resolving Host" & vbCrLf Case icHostResolved 'txtStatus.Text = txtStatus.Text & "Host Resolved" & vbCrLf Case icConnecting 'txtStatus.Text = txtStatus.Text & "Connecting to Host" & vbCrLf Case icConnected 'txtStatus.Text = txtStatus.Text & "Connected to Host" & vbCrLf Case icRequesting 'txtStatus.Text = txtStatus.Text & "Sending Request" & vbCrLf Case icRequestSent 'txtStatus.Text = txtStatus.Text & "Request Sent" & vbCrLf Case icReceivingResponse 'txtStatus.Text = txtStatus.Text & "Receiving Response" & vbCrLf Case icResponseReceived 'txtStatus.Text = txtStatus.Text & "Response Received" & vbCrLf Case icDisconnecting 'txtStatus.Text = txtStatus.Text & "Disconnecting from Host" & vbCrLf Case icDisconnected 'txtStatus.Text = txtStatus.Text & "Disconnected from Host" & vbCrLf Case icError txtStatus.Text = txtStatus.Text & vbCrLf & "An error occurred during the upload process" & vbCrLf If Err.Number = 0 Then MsgBox ("Directory already Exists") Else MsgBox (Err.Number & " " & Err.Description) End If exitEnabled = True Case icResponseCompleted 'YOUR CODE TO EXECUTE WHEN FINISHED GOES HERE end select
If you want to find out all the ftp commands - open your command prompt, run ftp and type help ftp
Sorry, the select case code goes in
Private Sub Inet1_StateChanged(ByVal State As Integer)
Just double click on the inet control to get this method.