ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / FTP functions
  • Security error in a secure FTPS connection (syntax 2)
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Connects the current computer to an FTP server (File Transfer Protocol).
Windows The available secure connection modes are as follows:
  • FTPS: FTP secured using SSL with implicit encryption.
  • FTPES: FTP secured using SSL with explicit encryption.
  • SFTP: FTP secured using an SSH tunnel.
New in SaaS
A new syntax for manipulating variables of type ftpConnection is available from WINDEV Suite SaaS 2025 - Update 2.
New in SaaS
// Syntax not available in PHP
// Connect the current computer to the FTP server
MyFTPConnection is ftpConnection
MyFTPConnection.Server = "192.54.12.8"
FTPConnect(MyFTPConnection)
// Connect the current computer to the FTP server
ResConnect = FTPConnect("192.54.12.8")
Syntax

Connecting to an FTP server (parameters specified in syntax) Hide the details

<Result> = FTPConnect(<Server> [, <Username> [, <Password> [, <Port number> [, <Type of connection> [, <Timeout> [, <Private key> [, <Key password>]]]]]]])
<Result>: Integer
  • Connection ID,
  • 0 during the first connection.
  • -1 if an error occurred. The details of the error are returned by ErrorInfo with the errCode or errMessage constant.
    If an authentication error occurs, ErrorInfo with the errCode constant returns the ftpErrorAuthentication constant.
<Server>: Character string
Name or IP address of the FTP server (for example, "ftp.cdrom.com" or "192.54.12.8").
Windows This parameter is used to define the protocol used:
  • if the server name starts with "ftp://", the connection is established in non-secure mode.
  • if the server name starts with "ftps://", the connection is established in secure mode using FTPS (FTP secured by implicit SSL encryption).
  • if the server name starts with "ftpes://", the connection is established in secure mode using FTPES (FTP secured by explicit SSL encryption).
  • if the server name starts with "sftp://", the connection is established in secure mode via an SSH tunnel using SFTP.
<Username>: Optional character string
  • Name of the user that tries to log in using login credentials. This parameter is set by FTP site administrator.
  • Empty string ("") for an anonymous connection.
<Password>: Optional string or Secret string
Password used to authenticate the user on the FTP server. This parameter is set by FTP site administrator.
This password corresponds to:
  • the specified <Password> if this parameter is not an empty string (""),
  • the email address of the user if <Username> is not specified or is an empty string (""),
  • an empty string ("") if this parameter is not specified and <Username> is not an empty string ("").
Note: If the password contains special characters, it may be necessary to convert it to UTF-8 using StringToUTF8.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "ANSI or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
<Port number>: Optional integer
Port number on which the server is to be run. This parameter is set by FTP site administrator.
By default:
  • for an insecure connection, this port is port 21.
  • Windows for a secure connection in FTPS mode, this port is port 990.
  • Windows for a secure connection in FTPES mode, this port is port 21.
  • Windows for a secure connection in SFTP mode, this port is port 22.
<Type of connection>: Optional Integer constant
Type of connection:
ftpActiveMode (or False for compatibility)Active connection to the FTP server.
In this mode, the client initiates the data connection. This type of connection may be refused by some protected FTP servers.
ftpExtendedPassiveModeExtended passive connection to the FTP server (EPSV command).
In this mode, the server initiates the data connection. This type of connection allows you to bypass some firewalls.
If the server does not support the extended passive mode (the FEAT command is sent to the server to get its capabilities), the connection is downgraded to simple passive mode.
Limitations:
  • This mode is not supported when using the Windows "wininet" module (see FTPConfigure). In this case, ftpPassiveMode is used.
ftpPassiveMode (or True for compatibility)
(Default value)
Passive connection to the FTP server (PASV command).
In this mode, the server initiates the data connection. This type of connection allows you to bypass some firewalls.
Note: If the connection to the server is established using IPV6, then the connection will be made in extended passive mode (passive mode does not support IPv6).
ftpPassiveModeIgnoreIPPassive connection to the FTP server (PASV command).
When transferring files in passive mode, the server sets the port and IP address for data transfer. With this parameter, only the port is taken into account. The IP address is ignored.
This type of connection allows the use of FTP servers that return non-routable IP addresses but are reachable via the connection IP address
Limitations:
  • This mode is not supported when using the Windows "wininet" module (see FTPConfigure). In this case, ftpPassiveMode is used.
<Timeout>: Optional integer or optional Duration
Number of seconds after which the request for connecting to the FTP server is canceled (20 by default). This timeout applies to all FTP operations performed on this connection. If no response is received from the server within the specified time, FTPConnect returns -1.
Note: This parameter can be:
  • an integer corresponding to the number of seconds,
  • a Duration variable,
  • the duration in a readable format (e.g., '1s').
<Private key>: Optional character string
Windows Name and path of file corresponding to the private key used during a connection in SFTP mode. This file must have been generated in OpenSSH format.
If this parameter is not specified, the secure connection uses <Username>/<Password> authentication.
<Key password>: Optional ANSI string or Secret string
Windows Password of file containing the private key used during a connection in SFTP mode.
If UNICODE strings are used at runtime ("Unicode" tab of the current configuration), the password must not be specified between quotation marks. It must be in a string variable declared in ANSI format.
If this parameter is not specified, the secure connection uses <Username>/<Password> authentication.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "ANSI or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
Remarks
Windows

Security error in a secure FTPS connection (syntax 2)

In a secure transaction, some security errors may cause the function to fail:
  • invalid certificate or certificate issued by an unknown organization.
  • site name in certificate does not correspond to a server.
  • invalid or expired certificate date.
The connection can still be established by ignoring these errors. To do so, use the FTP.IgnoreError variable:
Value of FTP.IgnoreError
(these values can be combined)
Description
ftpIgnoreInvalidCertificateIgnores the certificate.
ftpIgnoreExpiredCertificateIgnores the certificate date.
ftpIgnoreInvalidCertificateNameIgnores the site name specified in the certificate.
ftpIgnoreDeprecatedIgnores errors related to the use of deprecated algorithms (e.g. SHA-1 certificate signature).
ftpIgnoreUnsafeRenegotiationIgnores the error indicating that the server does not support secure renegotiation (RFC 5746).
ftpIgnoreRevocationIgnores certificate revocation.
// Example for error management
xnum is int
FTP.IgnoreError = ftpIgnoreExpiredCertificate + ftpIgnoreInvalidCertificate + ...
	ftpIgnoreInvalidCertificateName + ftpIgnoreRevocation
xnum = FTPConnect("ftpes://My_Server_IP", "My_User", "My_Password", 21, True)
IF xnum =-1 THEN
       Info(ErrorInfo(errMessage))
ELSE
       Info("OK")
END
Related Examples:
The FTP functions Unit examples (WINDEV): The FTP functions
[ + ] Using the main FTP functions of WINDEV:
- Connect to a FTP server
- List the files and directories found on the FTP server
- Retrieve the files found on the FTP server
- Disconnect from a FTP server
WD FTP File Transfer Complete examples (WINDEV): WD FTP File Transfer
[ + ] WD FTP file transfer

This example is a full FTP client allowing you to store several FTP servers. Then, you have the ability to perform multi-file transfers from the local computer to the server or from the FTP server to the local computer. To do so, we are using the standard functions of WLanguage (FTPConnect, etc...)
Business / UI classification: Business Logic
Component: wd300com.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/11/2025

Send a report | Local help