I recently needed to write a bash script for a CI-pipeline deployment and came across some useful snippets for using cURL to upload file via the FTP protocol. You can find the snippets below.

## What is cURL?

From Wikipedia:

cURL (pronounced ‘curl’) is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name stands for “Client URL”, which was first released in 1997.

## cURL with FTP

cURL is an immensely powerful library/command-line tool that enables you to execute CRUD operations against a number of different endpoints or using numerous protocols. Particularly for complex task execution with CI pipelines like TravisCI or CircleCI, it can be very helpful to upload a build step or generated assets to a webspace via FTP.

Here’s the list of the most useful snippets I found:

### Upload using cURL via FTP

If you plan to upload to a subdirectory, e.g.: ./mysubdir/test.xml, add the  --ftp-create-dirs flag to the command.

This command will upload all files in my-test-directory to the defined location at the FTP endpoint.