neilsav
neilsav

Reputation: 57

Use command line cURL to post contents of file

I am trying to use cURL to post data to a URL. The URL is expecting a <form> submission and the <textarea> field with a specified value. I have the value stored in a text file and I want to run cURL to post the contents of the data in the file to the web page. This is what I have - however I do not think I am correctly escaping the file location:

curl -data info='@filename.txt' https://file.com/test > tmp.txt

Upvotes: 4

Views: 1998

Answers (1)

Joni
Joni

Reputation: 111239

Looking at the man page, the correct syntax for sending the contents of a file as a POST variable is:

curl --data-urlencode '[email protected]' https://file.com/test > tmp.txt

Upvotes: 5

Related Questions