How to upload file via FTP / HTTP

The File Transfer Protocol (FTP) is an application we can use to transfer of files from one computer to another or, basically, any device in the world that is connected to the Internet. In this post, you will learn how to upload a file to an FTP server using Studio Pro.

Instructions

In this example, we use cURL, a program that you can access through the terminal (CMD) using the Command Prompt activity of Studio Pro. To do so, follow these steps:

  1. Use the Command Prompt activity located in OS Automation/System

  2. Select the “Calculate a value” option and enter the following command:

curl -s -T [LOCAL_FILE] ftp://[FTP_HOSTNAME]/[FTP_DIRECTORY_PATH]

Bear in mind that:

  • [LOCAL_FILE] is the file you want to upload to the FTP Server.
  • [FTP_HOSTNAME] is the name of the server you want to work with.
  • [FTP_DIRECTORY_PATH] is the directory in the FTP Server where you want to upload the [LOCAL_FILE].

For example, a complete upload file to FTP command would look like this:

curl -s -T test_photo.png ftp://ftp.example.com/dir/path/

mceclip1.png

This way you can upload any file to the desired FTP server just using the [LOCAL_FILE] as a variable.

Now, if you want to upload multiple files at the same time, do the following:

curl -s -T 'image[1-99].jpg' ftp://ftp.example.com/upload/

1curl -s -T '{Huey,Dewey,Louie}.jpg' ftp://ftp.example.com/nephews/

Complete detail about the cURL program can be found on cURL - How To Use.

Let us know below what you think.

Happy Automation with ElectroNeek!!!

2 Likes