Home MiscellaneousUpload multiple files using FTP in command line mode

Upload multiple files using FTP in command line mode

by SupportPRO Admin
Upload multiple files using FTP

Uploading files through FTP is a common task for system administrators and developers. When handling multiple files or entire directories, using command line FTP tools can save time and simplify file transfers.

One of the most efficient ways to upload multiple files using FTP is with the lftp command-line utility. It supports advanced file transfer features such as directory mirroring, recursive uploads, and automated synchronization.

In this guide, we will explain how to upload multiple files using FTP in command line mode with lftp.

What is lftp?

lftp is a powerful command-line FTP client available on Linux and Unix-based systems. It supports:

  • FTP
  • FTPS
  • SFTP
  • HTTP
  • HTTPS

The tool is widely used for transferring large numbers of files and managing remote servers efficiently.

Advantages of Using lftp

Using lftp offers several benefits:

  • Upload multiple files easily
  • Transfer entire directories recursively
  • Faster command-line file management
  • Resume interrupted transfers
  • Automate uploads through scripts
  • Synchronize local and remote directories

It is especially useful for server administrators managing websites and backups.

How to Upload Multiple Files Using FTP

Step 1: Connect to the FTP Server

Use the following command to connect to the FTP server:

lftp hostname

Replace hostname with your FTP server address.

Example:

lftp ftp.example.com

Step 2: Login to the FTP Server

After connecting, enter the FTP username and password:

user ftpusername ftppassword

Replace:

  • ftpusername → Your FTP username
  • ftppassword → Your FTP password

Download Entire Directory Using FTP

To download an entire directory from the remote server to the local system, use the mirror command.

mirror source destination

Example

mirror public_html /backup/public_html

This downloads the remote public_html directory to the local backup folder.

Upload Multiple Files Using FTP

To upload an entire directory or multiple files from the local system to the remote server, use the -R option with the mirror command.

mirror -R source destination

Example

mirror -R /home/user/website public_html

This uploads all files and directories from the local website folder to the remote public_html directory.

Understanding the mirror -R Command

The -R option means reverse mirror.

  • mirror → Downloads files from remote to local
  • mirror -R → Uploads files from local to remote

This feature makes it easy to synchronize entire directories without uploading files one by one.

Useful lftp Features

Resume Interrupted Transfers

lftp can automatically resume interrupted uploads or downloads, which is useful for large file transfers.

Recursive Directory Uploads

The mirror command uploads nested directories and files automatically.

Script Automation

You can automate FTP uploads by adding lftp commands inside shell scripts.

Example:

lftp -e "mirror -R /local/path /remote/path; quit" ftp.example.com

Common Issues While Uploading Multiple Files Using FTP

Authentication Failure

  • Verify FTP username and password
  • Check FTP account permissions

Permission Denied Errors

  • Ensure write permissions exist on the remote directory
  • Verify ownership and folder permissions

Connection Timeout

  • Check firewall settings
  • Confirm FTP service is running properly
  • Test internet connectivity

Conclusion

Uploading multiple files using FTP becomes much easier with the lftp command-line utility. By using the mirror and mirror -R commands, administrators can quickly transfer entire directories between local and remote systems.

The ability to automate uploads, resume interrupted transfers, and synchronize directories makes lftp an efficient solution for managing FTP file transfers in command line mode.

If you require help, contact SupportPRO Server Admin

Facing issues?

Our technical support
engineers can solve it.

Contact Us today!
guy server checkup

You may also like

Leave a Comment