Sample code for 30+ languages & platforms
PureBasic

chmod (Setting File Permissions)

See more FTP Examples

This example assumes your FTP server supports the "chmod" command, which typically means it must be a server running on a Linux or Unix system. The SendCommand method may be called to send arbitrary commands to the FTP server. This example sends a "chmod" command to set the file permissions.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkFtp2.pb"

Procedure ChilkatExample()

    success.i = 0

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

    ftp.i = CkFtp2::ckCreate()
    If ftp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkFtp2::setCkHostname(ftp, "ftp.cknotes.com")
    CkFtp2::setCkUsername(ftp, "myLogin")
    CkFtp2::setCkPassword(ftp, "myPassword")

    ; Connect and login to the FTP server.
    success = CkFtp2::ckConnect(ftp)
    If success <> 1
        Debug CkFtp2::ckLastErrorText(ftp)
        CkFtp2::ckDispose(ftp)
        ProcedureReturn
    EndIf

    ; Send a chmod command to the FTP server to set
    ; the permissions of a file to 0644:
    resp.s = CkFtp2::ckSendCommand(ftp,"chmod 0644 hamlet.xml")

    If CkFtp2::ckLastMethodSuccess(ftp) <> 1
        ; Failed.
        Debug CkFtp2::ckLastErrorText(ftp)
    Else
        ; You should write code to examine the response to
        ; the SendCommand.  As an example, the FTP server
        ; used for testing responds with this for success:
        ; 200 Permissions changed on hamlet.xml
        Debug resp
    EndIf

    success = CkFtp2::ckDisconnect(ftp)


    CkFtp2::ckDispose(ftp)


    ProcedureReturn
EndProcedure