例如如下form:
<form method="POST" action="junk.cgi">
<input type=text name="birthyear">
<input type=submit name=press value=" OK ">
</form>
curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when.cgi
你发送给服务器端的数据必须是已经被准确地编码了。curl不会自动帮你做此事。例如:如果你想使用包含了空格的数据,你需要使用%20来替换空格等。错误的请求将很可能造成你发送的数据错误,并出现混乱。新版本的curl能够执行URL编码的POST数据,比如:
# curl --data-urlencode "name=I am Daniel" http://www.example.com
<form method="POST" enctype='multipart/form-data' action="upload.cgi">
<input type=file name=upload>
<input type=submit name=press value="OK">
</form>
上面代码清楚地描述了将要发送内容的Content‐Type是multipart/form
‐data。 POST一个表单,如果使用CURL,则你只需要键入下面的命令:
# curl --form upload=@localfilename --form press=OK [URL]