curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication.

A list with full features is available on cURL site.

With this tool you can make server side requests (POST, GET…etc).

In this example, I want to POST a file along with some description to an external url.

curl -X POST \
--form "key=hgsdyt23hgsd" \
--form "article_id=1234"  \
--form "name=custom text" \
--form "file=@/tmp/myvideo.mkv" ""

Let’s explain this command:


-X, –request <command> Specifies a custom request method to use when communicating with the HTTP server. The specified request will be used instead of the method otherwise used (which defaults to GET). Common additional HTTP requests include POST, PUT and DELETE.

--form "key=1234"

-F, –form <name=content> This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data. 

--form "file=@/tmp/myvideo.mkv"

Send a file along other form data.

You can also explicitly change the name field of a file upload part by setting filename=, like this:

curl -F "file=@/tmp/myvideo.mkv;filename=lordoftherings.mkv"



cURL – upload files and submit data
Tagged on:                                     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.