Visual FoxPro
Visual FoxPro
Binary and ASCII FTP Transfer Modes
See more FTP Examples
The SetTypeBinary() and SetTypeAscii() method can be called to change the current transfer mode. The default transfer mode is binary. Once SetTypeAscii() or SetTypeBinary() is called, all subsequent transfers will occur in that mode.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.something.com"
loFtp.Username = "test"
loFtp.Password = "test"
* Connect and login to the FTP server.
lnSuccess = loFtp.Connect()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Set the transfer mode to ASCII
lnSuccess = loFtp.SetTypeAscii()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* 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"
* Turn on session logging for the upload:
loFtp.KeepSessionLog = 1
lnSuccess = loFtp.PutFile(lcLocalFilename,lcRemoteFilename)
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* View the session log. You can verify visually that
* the transfer was in ascii mode.
? loFtp.SessionLog
lnSuccess = loFtp.Disconnect()
? "File Uploaded!"
RELEASE loFtp