cURL – File Upload with Form Post on the Commandline

Q: How can use cURL to emulate a form post with a file upload?
A: It took me a bit of time to figure this out but it is quite straight forward really, you just need to use (possibly multiple) --form (or -F) arguments like this:

 
curl -F appID=1234 -F name=Emulate -F appFile=@em.zip http://www.abc.com/na
 

This will emulate a form post to

http://www.abc.com/na

with two named data items (appID and name) and one file upload, the file upload will be named ‘appFile’, the local file em.zip will be uploaded with the post, and that should do it!

3 replies

Comments are closed.