Wget当前仅支持x-www-form-urlenpred数据。
--post-file不是用于将文件作为表单附件传输,而是需要格式为的数据
key=value&otherkey=example。
--post-data并
--post-file以相同的方式工作:唯一的不同是,
--post-data您可以在命令行中指定数据,而
--post-file允许您指定包含要发送的数据的文件的路径。
这里是文档:
--post-data=string --post-file=fileUse POST as the method for all HTTP requests and send the specified datain the request body. --post-data sends string as data, whereas--post-file sends the contents of file. Other than that, they work inexactly the same way. In particular, they both expect content of theform "key1=value1&key2=value2", with percent-encoding for specialcharacters; the only difference is that one expects its content as acommand-line parameter and the other accepts its content from a file. Inparticular, --post-file is not for transmitting files as formattachments: those must appear as "key=value" data (with appropriatepercent-coding) just like everything else. Wget does not currentlysupport "multipart/form-data" for transmitting POST data; only"application/x-www-form-urlenpred". only one of --post-data and--post-file should be specified.
关于身份验证令牌,应该在标头,URL路径或数据本身中提供它。必须在您使用的服务的文档中的某处指出。在POST请求中,就像在GET请求中一样,您必须使用键和值指定数据。这样,服务器将能够接收具有特定名称的多个信息。变量也是如此。
因此,您不仅可以将魔术令牌发送到服务器,还需要指定密钥的名称。如果密钥是“令牌”,则应该是
token=YOUR_TOKEN。
wget --post-data 'user=foo&password=bar' http://example.com/auth.php
另外,如果可以的话,应该考虑使用curl,因为使用它可以更轻松地发送文件。互联网上有很多例子。



