CURL文件上传

记录一下

可以使用curl命令行工具来上传文件,具体方式如下:

curl -X POST -H "Content-Type:multipart/form-data" -F "file=@/path/to/file" <url>

其中:

  • -X POST指定请求方法为POST
  • -H "Content-Type:multipart/form-data"指定请求头为multipart/form-data
  • -F "file=@/path/to/file"指定上传的文件路径和文件参数名(这里使用的是file,可以根据实际情况修改)
  • <url>为上传文件的目标地址

例如,上传本地文件/Users/username/Documents/test.png到目标地址http://example.com/upload,命令如下:

curl -X POST -H "Content-Type:multipart/form-data" -F "file=@/Users/username/Documents/test.png" http://example.com/upload

猜你喜欢

转载自blog.csdn.net/qq_45795744/article/details/132708272
今日推荐