ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / FTP functions
  • Reminder about the FTP protocol
  • FTP commands
  • Example: Getting a TEST file found in the AAA library of an AS/400:
  • Use conditions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
FTPCommand (Function)
In french: FTPCommande
Sends a specific FTP command to a server.
Caution: This function is not available during a connection in mode:
  • FTPIS: FTP secured according to the SSL protocol with implicit encryption.
  • FTPES: FTP secured according to the SSL protocol with explicit encryption.
  • SFTP: FTP secured by a SSH channel.
PHP Sends a specific FTP SITE command to a server.
WEBDEV - Server codeAjax
// Connexion du poste en cours au serveur FTP
NumConnexion = FTPConnect("192.54.12.8")
// Demande du système du serveur
IF FTPCommand(NumConnexion, "SYST", Réponse) = True THEN
Info("Information sur le système du serveur: " + CR + Réponse)
ELSE
Info("Le serveur n'accepte pas la commande SYST." + ...
"L'information sur le système du serveur n'est pas disponible")
END
// Demande de la liste des fichiers du répertoire courant
IF FTPCommand(NumConnexion, "LIST", Réponse, MaListe) = True THEN
// Voici la liste des fichiers du répertoire en cours sur le serveur
Info("Voici la liste des fichiers du répertoire en cours sur le serveur: " + CR + MaListe)
END
WEBDEV - Server codePHP
// Connexion du poste en cours au serveur FTP
NumConnexion = FTPConnect("192.54.12.8")
// Création d'un groupe GroupeTest
IF FTPCommand(NumConnexion, "ADDGROUP GroupeTest") = True THEN
Info("Groupe GroupeTest créé")
ELSE
Info("Le serveur n'accepte pas la commande ADDGROUP.")
END
// Demande de la liste des fichiers du répertoire courant
IF FTPCommand(NumConnexion, "EXEC ls > list.txt") = True THEN
// La liste des fichiers du répertoire en cours sur le serveur est dans list.txt
Info("La liste des fichiers du répertoire" + ...
  " en cours sur le serveur est dans List.txt")
END
Syntax
WEBDEV - Server codeAjax

Sending a specific FTP command to a server Hide the details

<Result> = FTPCommand(<Connection identifier> , <FTP command> [, <Server response> [, <Result of command> [, <Transfer mode> [, <Data to send>]]]])
<Result>: Boolean
  • True if the command was run,
  • False if a problem occurred.
<Connection identifier>: Integer
Connection identifier, returned by FTPConnect.
<FTP command>: Character string
FTP command sent to the server.
<Server response>: Optional character string
Character string variable containing the server response for the specified FTP command. This parameter enables you to get the server response on the connection channel (the connection channel allows error or success messages to be received).
<Result of command>: Optional ANSI character string
ANSI Character String variable containing the data corresponding to the result of the specified FTP command. This result is returned by the server on the data channel.
Caution: If this parameter is specified, FTPCommand locks the computer until a result is received. More specifically, if the command does not expect a result through the data channel, the client is locked indefinitely. For more details, see the RFC959 specification.
<Transfer mode>: Optional Integer constant
Transfer mode used:
ftpASCIIModeTransfer performed in ASCII mode. This mode is used to transfer data between two different types of operating systems, from UNIX to Windows for example: the transferred file is changed into the ASCII format of destination system.
ftpBinaryMode
(Default value)
Transfer performed in binary mode: The file is strictly identical between the sending and the receiving.
<Data to send>: Optional character string
Data associated with the FTP command that will be sent to the FTP server. This data is sent through the data channel.
WEBDEV - Server codePHP

Sending an FTP SITE command to a server Hide the details

<Result> = FTPCommand(<Connection identifier> , <FTP command>)
<Result>: Boolean
  • True if the command was run,
  • False if a problem occurred.
<Connection identifier>: Variant
Connection identifier, returned by FTPConnect.
<FTP command>: Character string
FTP command sent to the server.
Remarks

Reminder about the FTP protocol

This protocol is using 2 communication channels:
  • A command channel: is used to send commands and to receive error or success messages,
  • A data channel used to transfer the data associated with the command.

FTP commands

All the commands that can be used on an FTP server are found in the RFC989 specification. This document is available on the Internet (use a search engine and search for the RFC959 reference).
Some standard examples: Uploading and downloading files with FTPCommand
1. Downloading files:
Réponse, ResData sont des chaînes
FTPCommande(<Identifiant de la connexion>, ...
"RETR " + <Nom Fichier serveur>, ...
Réponse, ResData, <Mode de transfert>)
// ResData contient le fichier
2. Uploading files:
Réponse, ResData, DataRésultat sont des chaînes
// ResData contient le fichier à envoyer
FTPCommande(<Identifiant de la connexion>,...
"STOR " + <Nom Fichier serveur>, ...
Réponse, DataRésultat, <Mode de transfert>, ResData)

Example: Getting a TEST file found in the AAA library of an AS/400:

Réponse, ResData are strings
IDFTP = FTPConnect("as400", "login", "MDP")
FTPCommand(IDFTP,"RETR " + "AAA/TEST", Réponse, ResData)
// ResData contient le fichier
fSaveText("C:\Tmp\test", ResData)
WEBDEV - Server codeWindowsAjax

Use conditions

The FTPCommand feature is available only if INTERNET Explorer 5 (or higher) is installed on the FTP Client machine.
Component: wd270com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help