Ariejan de Vroom

Uploading files with Curl

I’ve always trouble uploading files with Curl. Some how the syntax for that command won’t stick, so I post it here for future reference.

What I want to do is perform a normal POST, including a file and some other variables to a remote server. This is it:

curl -i -F name=test -F filedata=@localfile.jpg

You can add as many -F as you want. The -i option tells curl to show the response headers as well, which I find useful most of the time. ~

About Ariejan

Hey! I'm a software engineer building rock solid back-end systems using Ruby, Ruby on Rails and Golang. In my free time I like to repair audio equipment, play the piano and experiment with electronics.

I'd love to hear your questions and comments on this article! Mention me on twitter, shoot me an email or read more about me.