Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loFtp = createobject("CkFtp2")

loFtp.Hostname = "ftp.something.com"
loFtp.Username = "test"
loFtp.Password = "test"

// Connect and login to the FTP server.
llSuccess = loFtp.Connect()
if (llSuccess <> .T.) then
    ? loFtp.LastErrorText
    release loFtp
    return
endif

// Set the transfer mode to ASCII
llSuccess = loFtp.SetTypeAscii()
if (llSuccess <> .T.) then
    ? loFtp.LastErrorText
    release loFtp
    return
endif

// Change to the remote directory where the file will be uploaded.
llSuccess = loFtp.ChangeRemoteDir("junk")
if (llSuccess <> .T.) then
    ? loFtp.LastErrorText
    release loFtp
    return
endif

// Upload a file.
lcLocalFilename = "hamlet.xml"
lcRemoteFilename = "hamlet.xml"

// Turn on session logging for the upload:
loFtp.KeepSessionLog = .T.

llSuccess = loFtp.PutFile(lcLocalFilename,lcRemoteFilename)
if (llSuccess <> .T.) then
    ? loFtp.LastErrorText
    release loFtp
    return
endif

// View the session log.  You can verify visually that
// the transfer was in ascii mode.
? loFtp.SessionLog

llSuccess = loFtp.Disconnect()

? "File Uploaded!"


release loFtp