How Can I Post Files and JSON Data Together With Curl?

前端 未结 4 1179
别那么骄傲
别那么骄傲 2021-02-19 03:30

I\'ve been posting a file with this curl command:

curl -i -F file=@./File.xlsm -F name=file -X POST http://example.com/new_file/

Now I want to

4条回答
  •  情话喂你
    2021-02-19 03:48

    You could just add another form field:

    curl -X POST http://someurl/someresource -F upload=@/path/to/some/file -F data="{\"test\":\"test\"}"
    

    Note: due to the content type, this does not really equate to sending json to the web service.

提交回复
热议问题