【发布时间】:2012-12-28 01:03:58
【问题描述】:
我有一个关于 cURL 用法的简单问题。在我的 Google 搜索或手册页中没有找到太多明确的答案。
在here 中谈到使用--data 和--form 发送文件/附件。我很想知道主要区别是什么以及在什么情况下您会选择--data-binary VS --form?
POST“正文”可以通过--data (for application/x-www-form-urlencoded)或--form (for multipart/form-data)发送:
-F "foo=bar" # 'foo' value is 'bar'
-F "foo=<foovalue.txt" # the specified file is sent as plain text input
-F "foo=@foovalue.txt" # the specified file is sent as an attachment
-d "foo=bar"
-d "foo=<foovalue.txt"
-d "foo=@foovalue.txt"
-d "@entirebody.txt" # the specified file is used as the POST body
--data-binary "@binarybody.jpg"
【问题讨论】: