Whenever I try to upload files using curl, I seem to stumble over the syntax of the command. So, to avoid repeating the struggle, I’m documenting it here for my own future reference.

Here’s the deal: I aim to execute a standard POST request, bundling a file along with some additional variables, and dispatch it to a remote server. Here’s the breakdown:

curl -i -F name=test -F filedata=@localfile.jpg http://example.org/upload

Feel free to tack on as many -F flags as you need. And don’t forget about the -i option; it instructs curl to display the response headers alongside, a feature I often find handy.

My site is free of ads and trackers. Was this post helpful to you? Why not BuyMeACoffee


Reference:

  1. command line tool and library