[cURL] send a file via HTTP POST

### cURL POST file ###

Solution 1 :

curl -X POST --form "fileupload=@filename.txt" http://your_url.com
You can imagine that you have send a request above in the client side.
And how could I get the file that you have sent in the server side ?
[in PHP] :
$_FILES['fileupload']

Solution 2 :

curl -X POST -d @filename http://your_url.com/
### curl POST data ###
curl -X POST --data "param1=value1&param2=value2" http://your_url.com
[in PHP]:
Similar, to get the value of the parameters that have been sent
$_POST['param1']
$_POST['param2']


Here is the manuel that we can find all the options of cUrl :
http://curl.haxx.se/docs/manpage.html
Advertisements