posting data to a web server using curl

1

I am trying to post data to a web sever using curl -d and curl -X POST. The command is getting succeeded but nothing is there in the file. Tried the following:

[root@oooatis santoshi]# curl --data-urlencode "file=`cat write.pl`"          http://santoshi-dev-02.ocarina.local/bharat
[root@oooatis santoshi]# curl -X POST --data "file=`cat write.pl`" http://santoshi-dev-02.ocarina.local/bharat

But nothing is there in bharat on the host.

[root@Santoshi-DEV-02 html]# cat  /var/www/html/bharat

[root@Santoshi-DEV-02 html]#

user312107

Posted 2014-04-01T04:50:34.437

Reputation: 11

Answers

0

The HTTP server does not just dump the posted data into a file.

The request-URI needs to handle the post-data and do something with it. The URI is not a filename of a bucket for receiving the data. The URI needs to run as a process and handle the post-data as input.

The URI could be a script which parses the post-data and handles it in some way.

To provide your own POST-handler script, you will need to choose a scripting/programming language and create it.

I suggest that you work through some tutorials.

Here is one for Perl: http://www.tutorialspoint.com/perl/perl_cgi.htm

And another for PHP: http://www.tutorialspoint.com/php/php_get_post.htm

UnlimitedInfinity

Posted 2014-04-01T04:50:34.437

Reputation: 293