ftp

How to Upload Files with FTP

Last modified: December 1, 2022


Overview

This document explains how to use the command-line interface (CLI) or a third-party client to store files on your File Transfer Protocol (FTP) server.

Connect to an FTP server with a third-party client

If you open another program to connect to your FTP server, you are using a third-party FTP client. To connect to your FTP server with a third-party client, follow these steps:

  1. Create the FTP account in cPanel’s FTP Accounts interface (cPanel » Home » Files » FTP Accounts).
  2. Click Configure FTP Client next to the FTP account you want to connect to your third-party client.
  3. If we provide a configuration file for your third-party client, like Cyberduck® or WinSCP, download it from the Configuration Files section and open it on your local machine to configure your third-party client. If we do not provide a configuration file, you must configure the client manually.

Third-party clients have their own documentation for manual configuration, but will require the following information:

  • Server Protocol: FTP (File Transfer Protocol).
  • Server Name: Either your primary domain name or your site’s IP address.
  • User/Username: Your account name.
    Important:

    The username formatting must exactly match the information in the FTP Accounts interface (cPanel » Home » Files » FTP Accounts) for the third-party client to work. For example, if example.com is your primary domain name, your username will be formatted [email protected]. You can copy your formatted username from the Manual Settings section of the Configure FTP Client section.

  • Password: Your FTP password.
    Note:

    The FTP server’s port number defaults to 21, but is not always required. You can verify your FTP server’s port number in the Manual Settings section of the Configure FTP Client section in cPanel’s FTP Accounts interface (cPanel » Home » Files » FTP Accounts).

Connect to an FTP server from the command line

To connect to the FTP server from the CLI, follow these steps:

  1. Open a CLI window on your local machine.
  2. Enter the ftp command to open the File Transfer Protocol.
  3. Enter open to open a connection between your local machine and your FTP server. Your CLI window will look something like this:
    [[email protected] ~]: ftp
    ftp> open
    (to)
  4. In the (to) prompt, enter your server’s IP address. Depending on which FTP daemon you are using, your CLI window will now look something like this:
    [[email protected] ~]: ftp
    ftp> open
    (to) 0.0.0.0
    220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
    220-You are user number 1 of 50 allowed.
    220-Local time is now 15:34. Server port: 21.
    220-This is a private system - No anonymous login
    220-IPv6 connections are also welcome on this server.
    220 You will be disconnected after 15 minutes of inactivity.
    Name (0.0.0.0:example):
  5. Enter your FTP account’s username into the Name(0.0.0.0:example) prompt.
  6. Enter your FTP account’s password into the Password: prompt.

If you have entered the correct login information, the system will return a message similar to the following:

230 OK. Current restricted directory is /. 
Important:

If you have entered the incorrect login information, the system will return a message similar to the following:

530 Login authentication failed

Upload a file to an FTP server from the command line

To upload a file to your FTP server using the CLI, follow the documentation above to connect to an FTP server from the command line and then:

  • If you are not in the file’s desired destination folder, navigate there using the cd command. For example, to move a file to a server’s public_html folder so that it is visible to the site users, cd to public_html.
  • Use the put command to transfer the file from its current path. For example, to move the finalized-doc.txt file from the local machine’s unfinished-documents folder to your FTP server’s public_html folder to make it visible to site users, enter:
    ftp> cd public_html
    ftp> put localmachine:\unfinished-documents\finalized-doc.txt 
    Important:

    Your site’s root directory is set to the public_html folder. Uploading files into the / directory will not let site users view these files. Instead, to make files visible to your site’s users, you must put these files into the public_html folder.

Download a file from an FTP server from the command line

To download a file to your FTP server using the CLI, follow the documentation above to connect to an FTP server from the command line and then:

  • If you are not in the file’s current location on the FTP server, navigate there using the cd command. For example, files that are visible to site users will be stored in the public_html folder, so to download a file from there, cd to public_html.
  • Use the get command to transfer the file from its current path. For example, to download the document-with-a-mistake.txt file from the FTP server’s finalized-documents subfolder in the public_html folder, enter:
    ftp> cd public_html/finalized-documents
    ftp> get document-with-a-mistake.txt 

Additional Documentation