我登陆了这个旧版本,并在 Mac curl 的手册页中找到了这个答案。
-F, --form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a user has
pressed the submit button. This causes curl to POST data using
the Content-Type multipart/form-data according to RFC 2388.
Example: to send an image to a server, where 'profile' is the name
of the form-field to which portrait.jpg will be the input:
curl -F profile=@portrait.jpg https://example.com/upload.cgi
To read content from stdin instead of a file, use - as the
filename. This goes for both @ and < constructs. Unfortunately it
does not support reading the file from a named pipe or similar,
as it needs the full size before the transfer starts.
You can also tell curl what Content-Type to use by using 'type=',
in a manner similar to:
curl -F "web=@index.html;type=text/html" example.com
or
curl -F "name=daniel;type=text/foo" example.com
因此,我发送一个文本文件(html 表单字段名称结果)和一个 html 表单文本字段(名称 email_address)的方法如下:
curl -F "results=@results.txt;type=text/ascii" -F "email_address=auser@emailservice.com" http://mycollectorsite/my-collector.cgi
这是一个表单/cgi 处理导师,可以很好地使用这个 curl 发送命令:https ://www.sitepoint.com/uploading-files-cgi-perl/