Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' Upload a file. Return True if we are successful.
- Private Function UploadFile(ByVal source_file As String, _
- ByVal dest_file As String, ByVal host_name As String, _
- ByVal user_name As String, ByVal passwd As String) As _
- Boolean
- ' Get the file's contents.
- On Error GoTo UploadError
- ' You must set the URL before the user name and
- ' password. Otherwise the control cannot verify
- ' the user name and password and you get the error:
- '
- ' Unable to connect to remote host
- If LCase$(Left$(host_name, 6)) <> "ftp://" Then _
- host_name = "ftp://" & host_name
- inetFtp.URL = host_name
- inetFtp.UserName = user_name
- inetFtp.Password = passwd
- ' Do not include the host name here. That will make
- ' the control try to use its default user name and
- ' password and you'll get the error again.
- inetFtp.Execute , "Put " & source_file & " " & dest_file
- UploadFile = True
- Exit Function
- UploadError:
- MsgBox "Error " & Err.Number & _
- " uploading file '" & _
- source_file & "' to '" & _
- dest_file & "'." & vbCrLf & Err.Description, _
- vbExclamation Or vbOKOnly, _
- "Download Error"
- UploadFile = False
- Exit Function
- End Function
- ' Upload the file.
- Private Sub cmdUploadFile_Click()
- Screen.MousePointer = vbHourglass
- DoEvents
- If UploadFile(txtFromFile.Text, txtToFile.Text, _
- txtHostName.Text, txtUserName.Text, _
- txtPassword.Text) Then
- MsgBox "Upload Complete", _
- vbOKOnly Or vbInformation, _
- "Done"
- End If
- Screen.MousePointer = vbDefault
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement