首页 > 解决方案 > 如何发布两个文件

问题描述

我正在尝试使用命令发布两个不同的文件

curl -vX POST http://localhost/api/postJSON -d @input.json -d @input2.json --header "Content-Type: application/json"

我知道有些不对劲。有人对此有任何想法吗?

标签: jsonparsingpost

解决方案


查阅 curl 手册页并确定-F选项(https://curl.haxx.se/docs/manpage.html#-F)。

还有一个通过 curl 上传多个文件的示例,网址为https://medium.com/@petehouston/upload-files-with-curl-93064dcccc76#e822

$ curl -F 'fileX=@/path/to/fileX' -F 'fileY=@/path/to/fileY' ... http://localhost/api/postJSON upload

推荐阅读