FTP

Concept Link IconSee also Concept Link IconExample

Copies a file to or from an FTP server.

WebVue support - Yes. The runtime HMI display is not supported.

Mode

Mnemonic

Syntax

1 DOWNLOAD 1
2 UPLOAD 2

By design, FTP is considered a weak protocol as it transmits clear-text data over a TCP/IP network. It is obsolete and shall no longer be used. Use FTPS connections and the FTPS instruction instead.

Common Arguments

Argument

Meaning

HMIdisplay

Whether and how to display the progress dialog on a desktop client.

  • 0: None.
  • 1: Dialog without a Cancel button (default).
  • 2: Dialog with a Cancel button.

Type: INTEGER.

UserName

The user name of the account used to access the FTP server. If omitted, an anonymous login attempt is performed. Type STR.

Password

The password of the account used to access the FTP server. Type STR.

Syntax 1

FTP("DOWNLOAD", FtpFileSource, FileDestination [, HMIdisplay [, UserName, Password [, VariableName]]]);

Return type: INTEGER.

Argument

Meaning

FtpFileSource

The full path of the file to download e.g. "ftp://server/path”. Type STR.

FileDestination

The path to the local destination for storing the file. It can be an absolute path or a relative path from the TP project directory, but not a path to a FTP site. Type STR.

VariableName

The name of a register variable used to provide status indication.

  • 0: Transfer in progress.
  • 1: Completed.
  • 2: Canceled by the user.
  • 3: The remote server name cannot be resolved.
  • 4: Authentication failure.
  • 5: The source file for downloading does not exist.
  • 6: Logged on but permission denied.
  • 7: Transfer canceled - An error occurred.

Type STR.

If the variable does not exist, the FTP transfer may work but no status can be monitored. An information message is displayed in the Event Viewer.

Execution

Mode

Mnemonic

Action

1

DOWNLOAD

Copy a file from the FTP server to the local destination.

Return:

  • 0: No error.
  • -1: First argument is missing.
  • -2: Second argument is missing.
  • -3: Third argument is out of range.
  • -4: Unknown mode.
  • -5: The HMIDisplay is different from 0 and the HMI for file transfer is not supported in the execution context.

Syntax 2

FTP("UPLOAD", FileSource, FtpFileDestination [, HMIdisplay [, UserName, Password [, VariableName]]]);

Return type: INTEGER.

Argument

Meaning

FileSource

The full path of the file to be uploaded. It can be an absolute path or a relative path from the TP project directory, but not a path to a FTP site. Type STR.

FtpFileDestination

The path to the FTP destination. Type STR.

VariableName

The name of a register variable used to provide status indication.

  • 0: Transfer in progress.
  • 1: Completed.
  • 2: Canceled by the user.
  • 3: The remote server name cannot be resolved.
  • 4: Authentication failure.
  • 5: The source file for uploading does not exist.
  • 6: Logged on but permission denied.
  • 7: Transfer canceled - An error occurred.

Type STR.

If the variable does not exist, the FTP transfer may work but no status can be monitored. An information message is displayed in the Event Viewer.

Execution

Mode

Mnemonic

Action

1

UPLOAD

Copy a file from the local storage to the FTP server.

Return:

  • 0: No error.
  • -1: First argument is missing.
  • -2: Second argument is missing.
  • -3: Third argument is out of range.
  • -4: Unknown mode.
  • -5: The HMIDisplay is different from 0 and the HMI for file transfer is not supported in the execution context.

The HMI for file transfer

During transfer, a dialog is optionally displayed with both paths, the speed of data transfer and a progress bar. ClosedShow picture

The HMI for file transfer is not supported in WebVue. As a consequence, the HMIDisplay argument must be set to 0 for the instruction to be executed in a WebVue context. An error is returned and the instruction is not executed in WebVue context if any other value is passed.

Example

For an example, select the Example link at top of page.