PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • 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/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.
Reports and Queries
// 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
Syntax
Reports and Queries

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).
<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.
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)
Reports and QueriesWindows

Use conditions

FTPCommand is available only if Internet Explorer 5 (or later) is installed on the computer of the FTP client.
Component : wd250com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment