Uploading a file with curl

To submit the file at foo to a web service as multi-part form data using curl:

curl -X POST -F "file=@\"foo\"" 'https://127.0.0.1/example'

The file part is the name of the corresponding form field.

Note that you can submit multiple files:

curl -X POST -F "f1=@\"foo\"&f2=@\"bar\"" 'https://127.0.0.1/example'

Or add additional body or query string parameters:

curl -X POST -F "f1=@\"foo\"&x=y" 'https://127.0.0.1/example?a=b'
Published 31 Dec 2015
Tagged curl, web and tool.

 

This page was generated at 4:16 PM on 26 Feb 2018.
Copyright © 1999 - 2018 Rodney Waldhoff.