CURL upload file allows you to send data to a remote server. The command-line tool supports web forms integral to every web system.
When you execute a CURL file upload  for any protocol (HTTP, FTP, SMTP, and others), you transfer data via URLs to and from a server. In this post, I’ll guide you through uploading file data using the HTTP protocol on CURL successfully. But before we dive into the nitty-gritty…
Table of Contents
What is CURL?
CURL stands for client URL. It is a command-line tool built to send data from or to a remote server using various network protocols such as HTTP, FTP, FILE, IMAP, SBM, SMTP, and others.
CURL runs on Windows, Linux, and macOS platforms. It also has built-in support for HTTP cookies, SSL, user authentication, proxies, and certificate validation.
Since 1998, developers use CURL as a command-line tool and library for transferring data with URLs. It works as both a separate console application as well as compiled as a dynamic library into other programs.
You also can use CURL to download or upload files, submit web forms, send a request to API endpoints, and simulate user actions without using a web browser.
How to Install CURL?
You can install and use CURL on Windows, macOS, and Linux operating platforms.
For Windows, follow these steps:
- Download the CURL Windows installer from the CURL official website  (64-bit recommended).
- Unzip the Curl.zip file into a folder on your computer (i.e., C:\Curl).
- Invoke the CURL command from any folder, including the CURL installation folder (C:\Curl\bin), to your Windows PATH environment variable.
curl –versionon the Windows command line to check if it was installed correctly and ensure you can use Curl commands.
If you installed it correctly, you’ll get this response:
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
Release-Date: 2017-11-14, security patched: 2019-11-05
Protocols: dict file ftp ftps http https imap imaps pop3 pop3s smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL
For macOS, CURL comes pre-installed on the operating system.
You can decide to update to the latest CURL version by installing macOS Homebrew Software Package Manager.
After installing the Homebrew Package Manager, open a terminal and type:
brew install curl
If installed properly, you’ll get the response below when you type
curl 7.31.0 (x86_64-apple-darwin12.4.0) libcurl/7.31.0 OpenSSL/0.9.8x zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: IPv6 Large File NTLM NTLM_WB SSL libz
For Linux/Ubuntu, you need to enter the following command in a terminal.
sudo apt install curl
sudo apt-get install curl
And to verify if CURL is correctly installed and working, run the curl –version command in a terminal. If positive, you’ll get the response below:
curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.1.1 zlib/1.2.11 libidn2/2.0.4 libpsl/0.19.1 (+libidn2/2.0.4) nghttp2/1.30.0 librtmp 2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
You can learn more about CURL, its installation, and its usage here .
Guide to CURL File Upload?
Uploading files using CURL is pretty straightforward once you’ve installed it.
Several protocols allow CURL file upload including: FILE, FTP, FTPS, HTTP, HTTPS, IMAP, IMAPS, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, and TFTP.
Each of these protocols works with CURL differently for uploading data.
For HTTP (and HTTPS), it offers several ‘uploads’ methods to upload data to a server. CURL provides easy command-line options to do it in the three common ways:
- Multipart from posts
Let’s take a look at the HTTP protocol and several ways you can execute CURL upload data with it!
POST is an HTTP file upload method created to send data to a receiving web application. Many HTML forms on the web rely on this method to work.
POST method uses the e –d or –data options to deliver a chunk of relatively small amounts of data to the remote server (and receiver).
After data has been filled in a form, a browser URL encodes and sends it as a serialized name=value pairs separated with ampersand symbols (&).
curl -d 'name=admin&shoesize=12' http://example.com/
Send the data using curl’s –d or –data option.
To execute a CURL file upload, you need to use the –d command-line option and begin data with the @ symbol.
The file’s name should come after the data with @ symbol so CURL can read it and send it to the server.
curl -d @path/to/data.json https://reqbin.com/echo/post/json
Are you sending data with a custom content type?
Use the –H command-line option instead and specify your content type.
You can read more about the CURL HTTP POST file upload method here .
Multipart form post
HTTP Multipart form posts are also widely used to upload files in HTML forms on the web. Do this using the –F data option.
This file upload method is also an HTTP POST but it sends the data formatted differently according to some rules. This is where the term “multipart” comes into play.
Since the data format the server receives is different, you can’t pick a type of POST to use. This depends on the server; on what it expects and can handle.
To send an HTML form with CURL multipart form posts, you need to add each multipart with one –F (or –form) option and add one –F for every input field in the form.
curl -F person=anonymous -F email@example.com http://example.com/submit.cgi
You can read more about the HTTP multipart form post method here .
PUT is the least used CURL file upload HTTP method in HTML forms on the web, and a lot of servers don’t have PUT enabled.
It delivers complete resources meant to be sent as-is on the remote site. Or it could even replace an existing resource there.
To send files using the PUT method, you need to use the –T data option.
curl -T uploadthis http://example.com/
You can read more about the HTTP PUT method here .
Should I Use CURL Upload File?
If you’re looking for seamless file upload between your browser and a remote server, you should consider using CURL.
CURL is a command-line tool and library for transferring data from and to remote servers.
It works well with web forms and is a great fit for file upload on your web application.
Are you ready to start enjoying a seamless CURL upload file experience?
Then, you need to start with Filestack.
Can Filestack Streamline the Process of doing File Uploads?
Filestack is a solution that offers a set of robust technology tools and API to improve your file upload experience.
It features a powerful, easy-to-use API to fetch user content from anywhere and improves your file upload experience.
When it comes to fast and seamless file uploads, URL ingestion, or iOS/Android device integration, Filestack has got you covered!
Head over to Filestack and sign up for free.
Your journey to a seamless file uploading experience starts here!
Read More →