Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Code Help

Status
Not open for further replies.

DWillett

Programmer
Oct 21, 2003
5
GB
I'm trying to set up an FTP Upload and Download routine in my application.
I've not used the INET control before so am not familiar with the commands etc.

I'm trying to do this without any GUI other than a command button firstly as an example.

The following code doesn't work and am pulling my hair out.
The Upload function is extremely important, more so than the Download.

The files will be Images, uploaded to a known Server and path.
Can anyone help in this ??

Option Explicit

Function UploadFile(ByVal HostName As String, _
ByVal UserName As String, _
ByVal PassWord As String, _
ByVal LocalFileName As String, _
ByVal RemoteFileName As String) As Boolean

Dim FTP As Inet

Set FTP = New Inet

With FTP

.Protocol = icFTP
.RemoteHost = HostName
.UserName = UserName
.PassWord = PassWord
.Execute .URL, "Put " + LocalFileName + "" + RemoteFileName
Do While .StillExecuting
DoEvents
Loop
UploadFile = (.ResponseCode = 0)
End With
Set FTP = Nothing
End Function

Private Sub Command1_Click()
UploadFile "IP#.##.###.###", "MyUserName", "MyPassWord", "L:\MMPDF\Image\99999-91.jpg", "L:\MMPDF\Image\99999-91.jpg"

End Sub


Ip,User & Password changed for site security.
 
You need a space between the from and to file names:

.Execute .URL, "Put " + LocalFileName + "" + RemoteFileName

-->

.Execute .URL, "Put " + LocalFileName + [red]" "[/red] + RemoteFileName

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top