# Using High-Level Versus Low-Level FTP Functions

The LabWindows/CVI Internet Library provides both high–level and low–level functions to execute FTP operations. The high–level functions simplify the process of logging on to an FTP server, sending files to or retrieving files from the server, and logging out of the server. However, if the FTP-client application runs behind a firewall, you might need to use the low–level functions to avoid errors. The low-level InetFTPSetPassiveMode function allows you to turn on passive mode, which is generally the required mode for FTP data connection behind a firewall.

The following examples demonstrate how to use both high–level and low–level functions to transfer files across an FTP connection.

## Using High–Level Functions

The following function call copies the README file from the ftp.ni.com FTP server to a local file c:\temp\README. The function performs an anonymous login and expects to find the README file in the default login directory of the FTP server. The call performs the file transfer in text (ASCII) mode.

InetFTPAutoRetrieve ("ftp.ni.com", "anonymous", "joeb@oilrig.com", "c:\\temp\\README", "README", INET_FTP_FILE_TYPE_ASCII);

The following call copies the c:\data\sept.log local file to the logfiles directory on the ftp.oilrig.com FTP server. The function logs in as joeb with password j12b345.

InetFTPAutoSend ("ftp.oilrig.com", "joeb", "j12b345", "c:\\data\\sept.log", "logfiles\\sept.log", INET_FTP_FILE_TYPE_BINARY);

## Using Low–Level Functions

You also can use the following low–level FTP function calls to transfer the sept.log file. Notice that you can specify the data connection mode with the low–level InetFTPSetPassiveMode function.

int ftpHandle;

ftpHandle = InetFTPLogin ("ftp.oilrig.com", "joeb", "j12b345");

InetFTPSetPassiveMode (ftpHandle, 1);

InetFTPSendFile (ftpHandle, "c:\\data\\sept.log", "logfiles\\sept.log", INET_FTP_FILE_TYPE_BINARY);

InetFTPClose (ftpHandle);