Visual FoxPro
Visual FoxPro
PassiveUseHostAddr
See more FTP Examples
Some FTP servers need this option for passive data transfers. In passive mode, the data connection is initiated by the client sending a PASV command to the FTP server, and the FTP server responds with the IP address and port number where it is listening for the client's connection request. When the PassiveUseHostAddr property is set, the IP address in the PASV response is discarded and the IP address of the remote endpoint of the existing control connection is used instead.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loFtp
LOCAL lcLocalFilename
LOCAL lcRemoteFilename
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loFtp = CreateObject('Chilkat.Ftp2')
loFtp.Hostname = "ftp.example.com"
loFtp.Username = "login"
loFtp.Password = "password"
* Connect and login to the FTP server.
lnSuccess = loFtp.Connect()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Set the PassiveUseHostAddr property.
loFtp.PassiveUseHostAddr = 1
* Change to the remote directory where the file will be uploaded.
lnSuccess = loFtp.ChangeRemoteDir("junk")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Upload a file.
lcLocalFilename = "hamlet.xml"
lcRemoteFilename = "hamlet.xml"
lnSuccess = loFtp.PutFile(lcLocalFilename,lcRemoteFilename)
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
lnSuccess = loFtp.Disconnect()
? "File Uploaded!"
RELEASE loFtp