How to upload a file to remote FTPS with cURL and PHP

You may need to upload a file to remote FTP or FTPS in a number of cases. In this article I’m going to show you how to upload file with cURL from Linux shell and using cURL in PHP.

Upload file to FTPS with cURL using bash

Here is the command that will upload a file to FTPS from bash command line using cURL:

-v – Verbose mode. Shows how the process goes.

--ftp-ssl – Try to use SSL/TLS for the FTP connection. Reverts to a non-secure connection if the server doesn’t support SSL/TLS. Without this key attempt to upload file to FTPS will end up with error 550 SSL/TLS required on the control channel

--insecure – Allows curl to perform “insecure” SSL connections and transfers. All SSL connections are attempted to be made secure by using the CA certificate bundle installed by

-T – path to file for upload

--user – credentials for connection in form username:password

Upload file to FTPS with cURL in PHP script

Here is an example of PHP script for uploading file to FTP(S):

Have fun!


Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [dot] com