PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Reminder about the FTP protocol
  • FTP commands
  • Example: Getting a TEST file found in the AAA library of an AS/400:
  • Use conditions
  • Required permissions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
FTPCommand (Function)
In French: FTPCommande
Sends a specific FTP command to a server.
Versions 18 and later
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.
New in version 18
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.
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.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Android Widget This function is now available in Android Widget mode.
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget Windows MobileJavaAjaxUser code (UMC)
// Connect the current computer to the FTP server
ConnectionNum = FTPConnect("192.54.12.8")
// Request from the server system
IF FTPCommand(ConnectionNum, "SYST", Response) = True THEN
Info("Information about the server system: " + CR + Response)
ELSE
Info("The server does not support the SYST command." + ...
"No information about the server system is available")
END
// Ask for the list of files found in the current directory
IF FTPCommand(ConnectionNum, "LIST", Response, MyList) = True THEN
// The list of files found in the current directory on the server is as follows
Info("List of files found in the current directory on the server: " + CR + MyList)
END
WEBDEV - Server codePHP
// Connect the current computer to the FTP server
ConnectionNum = FTPConnect("192.54.12.8")
// Create a group named TestGroup
IF FTPCommand(ConnectionNum, "ADDGROUP TestGroup") = True THEN
Info("The TestGroup group was created")
ELSE
Info("The server does not accept the ADDGROUP command.")
END
// Ask for the list of files found in the current directory
IF FTPCommand(ConnectionNum, "EXEC ls > list.txt") = True THEN
// The list of files found in the current directory on the server is stored in list.txt
Info("The list of file in the current" + ...
  " directory on the server is stored in List.txt")
END
Syntax
WINDEVWEBDEV - Server codeWINDEV MobileReports and QueriesAndroidAndroid Widget Windows MobileJavaAjaxUser code (UMC)

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 (with quotes)
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).
Windows Mobile This parameter can correspond to a character string or to a buffer:
  • If this parameter corresponds to a character string, this string is automatically converted into UNICODE in order to be processed by the Mobile (use of the FTP LIST command for example).
  • If this parameter is a buffer, no conversion is performed (use the FTP RETR command to retrieve a file for example: no conversion is required).
<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. See the RFC959 specification for more details.
<Transfer Mode>: Optional Integer constant
Transfer mode used:
ftpBinaryMode
(Default value)
Transfer performed in binary mode: The file is strictly identical between the sending and the receiving.
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.
<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 (with quotes)
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:
Response, ResData are strings
FTPCommand(<Connection Identifier>, ...
"RETR" + <Name File Server>, ...
Response, ResData, <Transfer Mode>)
// ResData contains the file
2. Uploading files:
Response, ResData, DataResult are strings
// ResData contains the file to upload
FTPCommand(<Connection Identifier>,...
"STOR " + <Name File Server>, ...
Response, DataResult, <Transfer Mode>, ResData)

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

Response, ResData are strings
FTPID = FTPConnect("as400", "login", "PWD")
FTPCommand(FTPID,"RETR " + "AAA/TEST", Response, ResData)
// ResData contains the file
fSaveText("C:\Tmp\test", ResData)
WINDEVWEBDEV - Server codeReports and QueriesWindowsAndroidAndroid Widget Windows MobileJavaAjaxUser code (UMC)

Use conditions

FTPCommand is available only if Internet Explorer 5 (or later) is installed on the computer of the FTP client.
AndroidAndroid Widget

Required permissions

The call to this function modifies the permissions required by the application.
Required permission : INTERNET
This permission allows the applications to open the network sockets.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230com.dll
Windows Mobile wp230com.dll
Java wd230java.jar
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment