apache - How to send a file to a server using curl? -
first off, know square root of sod curl , i'm not trying learn it. i'm told might me out tracking down problem in c code trying write data apache server. may barking completely wrong tree here.
what want do http post laptop desktop running http server, see raw http using wireshark. can go c code on embedded board better idea of how working.
i have tried following command:
curl -x post -d @test.txt 192.168.0.106/incoming
where text.txt contains "hello world" in plain text (created vim). .106 apache server...which serves files nicely command.
but gives:
warning: couldn't read data file "test.txt", makes empty post. <!doctype html public "-//ietf//dtd html 2.0//en"> <html><head> <title>301 moved permanently</title> </head><body> <h1>moved permanently</h1> <p>the document has moved <a href="http://192.168.0.106/incoming/">here</a>.</p> </body></html>
many thanks!
my understanding:
you want send data laptop apache server , save contents in incoming
folder.
how this:
for this, need something receive data sending curl. suggest create index.php
inside incoming folder. depending on curl command using, can have in index.php
.
index.php
<?php move_uploaded_file($_files['content']['tmp_name'], "test.txt"); ?>
if going use:
curl --form "content=@test.txt" http://192.168.0.106/incoming/
otherwise, this:
index.php
<?php file_put_contents("test2.txt", $_post['content']); ?>
with
curl --data-urlencode "content@test.txt" http://192.168.0.106/incoming/
Comments
Post a Comment