ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Communication / FTP functions
  • Security error in a secure FTPS connection (syntax 2)
  • Required permissions
  • Required configuration
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).
WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget 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
// Syntaxe non disponible en PHP
// Connexion du poste en cours au serveur FTP
MaConnexionFTP is ftpConnection
MaConnexionFTP.Server = "192.54.12.8"
FTPConnect(MaConnexionFTP)
// Connexion du poste en cours au serveur FTP
ResConnecte = FTPConnect("192.54.12.8")
Syntax
New in SaaS
PHP Syntax not available in PHP

Connecting to an FTP server using an ftpConnection variable Hide the details

<Result> = FTPConnect(<FTP connection>)
<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.
<FTP connection>: ftpConnection variable
Name of the ftpConnection variable that describes the characteristics of the connection to the FTP server.
Note: This variable type is only available from WINDEV Suite SaaS 2025 - Update 2.

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.
PHP This parameter is a Variant parameter that corresponds to the connection identifier or -1 if an error occurs.
<Server>: Character string
Name or IP address of the FTP server (for example, "ftp.cdrom.com" or "192.54.12.8").
WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget 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.
New in version 2025
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.
<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.
  • WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget for a secure connection in FTPS mode, this port is port 990.
  • WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget for a secure connection in FTPES mode, this port is port 21.
  • WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget 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.
  • AndroidAndroid Widget Java Constant not available.
  • PHP This constant is identical to the ftpPassiveMode.
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.
  • AndroidAndroid Widget PHP Constant not available.
<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').
PHP This parameter corresponds to an integer.
<Private key>: Optional character string
WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget 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
WINDEVWEBDEV - Server codeWindowsAndroidAndroid Widget 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.
New in version 2025
AndroidAndroid Widget Secret strings are not available for this parameter in Android/Android widget applications.
Remarks
WINDEVWEBDEV - Server codeWindowsLinux

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.
// Exemple de gestion des erreurs
xnum is int
FTP.IgnoreError = ftpIgnoreExpiredCertificate + ftpIgnoreInvalidCertificate + ...
	ftpIgnoreInvalidCertificateName + ftpIgnoreRevocation
xnum = FTPConnect("ftpes://Mon_Ip_Server", "Mon_User", "Mon_Password", 21, True)
IF xnum =-1 THEN
       Info(ErrorInfo(errMessage))
ELSE
       Info("OK")
END
AndroidAndroid Widget

Required permissions

This function changes the permissions required by the application.
Required permission: INTERNET
This permission allows the applications to open the network sockets.
PHP

Required configuration

In PHP, the ftp module must be enabled.
To enable this library locally, the PHP.INI file located in the Windows directory must include the "extension=php_ftp.dll" line.
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: 05/16/2025

Send a report | Local help