|| 3.60 out of 5
How Do I Transfer Files with FTP?
Primary Software Version:
Primary Software Fixed Version:
How do I send files to my LabVIEW Real-Time (RT) controller's FTP server or send files to ftp.ni.com/incoming for support purposes?
There are a number of parameters that are necessary to know when connecting to an FTP server.
In many cases all you will know is the FTP server name or IP address. This is not a problem because all the other values have a sort of default value that gets used if not specified. The default port number is 21. The default username usually used is anonymous. The default password for the anonymous user is any email address. Some FTP servers will accept even a blank password, others do some basic string parsing to make sure what you entered is in email address format. It is generally recommended that you use your email address for the password.
- FTP server name or IP address
- Port number
There are three basic ways to communicate with an FTP server.
Let's look at each of these methods in a little more detail.
- Use a web browser as your FTP client
- Use the command-prompt FTP client
- Use a graphical FTP client
It is also possible to to use a Windows Explorer window as a graphical FTP client. To do this, open a Windows Explorer window and type
- Most web browsers (including Internet Explorer and Netscape) will work as an FTP client. They are particularly easy to use if your goal is to download something from the FTP server you are connecting to. Depending which browser you are using and even which version you have, uploading and deleting files may or may not be possible. In general, in the URL field of your web browser, type in ftp://ftp.ni.com or click on this link to the National Instruments FTP server. The ftp:// tells your web browser that whatever comes next is an FTP server, and should be connected to via the File Transfer Protocol (FTP) instead of as a web page (HTML). The ftp.ni.com gets replaced by the name or IP address of the FTP server you need to connect to. When you use this URL, the default port number, username, and password are all used. If you need to connect to an FTP server running on a different port or with a different username or password, the full format for this is ftp://username:password@ftp_server_name:port_number. Once connected, depending on your web browser, use basic Windows operations to access the files. Usually either single- or double-clicking on a file will download it. Doing the same to a folder will open that directory. To upload a file, try dragging and dropping it from your Windows computer into the web browser window. As mentioned, this does work in some web browsers, but in others you may experience problems uploading files. A few other possible causes for uploading errors is that some FTP servers do not allow write access, do not accept files with spaces in the file name, or do not accept files with long file names.
- Starting with Windows 95, Windows comes with a command-line FTP utility. While not as easy to use as Internet Explorer for some operations, things like uploading files are more reliable using this method. To use this utility, launch a command prompt in Windows and type ftp and hit enter. This utility operates almost identically to the UNIX-based utility of the same name which has been around for many years. If you are unfamiliar with this utility, the most useful command is simply ?. Entering this command and hitting enter will display a list of commands that the command-line FTP client understands. You can then type ? command to display a brief line of help about that command. Some of the most useful FTP commands are shown here:
- open - Opens an FTP session with an FTP server. If used by itself it will prompt for the FTP server name or IP address. Alternatively you can type open ftp_server_name to connect to a specific FTP server using a single line. This is where you can specify the port number as well, by entering an additional parameter at the end of the command line: open ftp_server_name port_number. If you do not specify the port number, it will assume you are connecting on the default FTP port. One last way to connect using the default port number is, instead of just typing ftp to launch the FTP utility at your Windows command-prompt, type ftp ftp_server_name. After opening a connection, you will be asked to enter a username followed by a password. This is where you can enter the default username and password discussed above, or enter a specific one if applicable.
- dir - Lists all files and directories in the current directory. The file names are listed on the right hand side of the window. Just to the left is the time and date of the last time the file was modified. To the left of that is the file size in bytes. On the far left is a series of letters and dashes that describe the permissions of each file. We will not go into detail on file permissions, but it is important to point out that if the left-most character in this block is a d then the item is a directory. If this left-most character is a - then it is a file.
- cd - Changes directories on the remote FTP server. Usage would be simply cd directory_name. If directory_name contains any spaces, it must be surrounded by quotation marks.
- lcd - Changes directories on the local PC. Usage is identical to cd except the current directory on your PC is changed instead of on the remote FTP server. One useful technique that Windows supports is dragging and dropping a file or folder into a command prompt window. Sometimes typing a full path can be very long in Windows. First type lcd, then switch to a Windows Explorer window and drag the folder from Windows Explorer over into the command-prompt window. It will type the full path to that folder into the command-prompt Window automatically. Notice that it will be surrounded by quotation marks if there are any spaces, as is required.
- binary - Sets the file transfer mode to binary mode. This is often overlooked and can be a common cause of file transfer problems. Binary mode should always be used for file transfers. To be on the safe side, it is recommended to always enter this command by itself on a blank line to set binary transfer mode before performing any file transfers with the FTP server.
- get - Downloads a file from the FTP server. Typical usage would be get remote_filename. This would look for remote_filename in the current remote FTP server directory and if it exists it will download it to the current local PC directory. If remote_filename contains any spaces, it must be surrounded by quotation marks.
- put - Uploads a file to the FTP server. Typical usage would be put local_filename. This would look for local_filename in the current local PC directory and if it exists it will upload it to the current remote FTP server directory. If local_filename contains any spaces, it must be surrounded by quotation marks. As with using a web browser to upload files, common problems encountered uploading files are that some FTP servers do not allow write access, do not accept files with spaces in the file name, or do not accept files with long file names.
- mkdir - Creates a directory on the remote FTP server. Usage would be mkdir new_remote_directory. Like uploading files, you may not have access to create new directories on an FTP server.
- delete - Removes a file from the remote FTP server. Usage would be delete remote_filename. Like uploading files, you may not always have access to delete files from an FTP server.
- rmdir - Removes a directory from the remote FTP server. Usage would be rmdir remote_directory. The directory must be empty before rmdir will work. Like uploading files, you may not always have access to remove directories from an FTP server.
- quit - Logs off from the FTP server if connected and quits the FTP utility.
- Windows does not come with a dedicated graphical FTP client program. You would need to download one from the link below. They vary in quality and price, but in general the right graphical FTP client is going to give the most flexibility and control of the FTP server. Because there are so many different graphical FTP clients, we will not go into detail on the operation on any one in particular, but once familiar with the features they are more powerful and easier to use than the command prompt or web browser approaches.
ftp://X.X.X.X where 'X' symbolizes the IP address of the controller. You can then copy and paste files to or from the server.
External Link: FileZilla - The free FTP solution
KnowledgeBase 3UJACBE9: FTP Transfer of Files between Host and Real-Time Targets in Measurement & Automation Explorer (MAX)
Knowledgebase 2KM92E5F: Using FTP to Access and Use the External CompactFlash or USB Drive on a Real-Time Controller
Knowledgebase 4P4B654H: How Can I Use LabVIEW to FTP Files to and from My Real-Time Target
Report Date: 09/23/2002
Last Updated: 05/01/2014
Document ID: 2PM9CMEW