How to send file contents as body entity using cURL

curl, post

Solution

I believe you're looking for the `@filename` syntax, e.g.:

strip new lines

curl --data "@/path/to/filename" http://...

keep new lines

curl --data-binary "@/path/to/filename" http://...

curl will strip all newlines from the file. If you want to send the file with newlines intact, use `--data-binary` in place of --data

Problem

I am using cURL command line utility to send HTTP POST to a web service. I want to include a file's contents as the body entity of the POST. I have tried using `-d </path/to/filename>` as well as other variants with type info like `--data </path/to/filename> --data-urlencode </path/to/filename>` etc... the file is always attached. I need it as the body entity.

Original source