- 发送post请求发送图片 前面指具体路径文件名 后面指传输的文件名
curl
-F "pic=@/mnt/shared/Image/jpg/Screensho1t.jpg; filename='Screensho1t.jpg'"
http://127.0.0.1:8080/picture
- 多图上传
curl -X POST -F 'image=@/path/to/pictures/picture.jpg' http://xxxx/upload
curl
-F "pic=@/mnt/shared/Image/jpg/1.jpg; filename='1.jpg'"
-F "pic=@/mnt/shared/Image/jpg/2.jpg; filename='2.jpg'"
- curl发送post请求 支持多个header头部
curl http://ip:port/service/name/op -X POST -H "Content-type:application/json" -d ' json参数 '
curl http://ip:port/message/messageList -X POST -H "Content-Type:application/json" -H "XXX:XXXX" -H "" -d '{"XXXX":"XXX","pageNum":1,"pageSize":20}'
- 发送formdata数据
curl -X POST -F 'accountId=xxxxxx' -F 'meetingId=xxxx' -F 'type=1' http://192.168.10.126:8088/api/web/xxxx/checkState
- urlencoded
curl -d "param1=value1¶m2=value2" -X POST http://localhost:3000/data
curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:3000/data
- 其他常见命令
-I/–head 只显示响应header,经常用于测试连接本身
-L/–location 跟踪重定向
-s/–silent 静默模式,不输出任何东西
-S/–show-error 显示错误,在选项 -s 中,当 curl 出现错误时将显示
-o/–output 把输出写到该文件中,必须输入保存文件名
-O/–remote-name 把输出写到该文件中,保留远程文件的文件名
-w/–write-out [format] 传输完成后再输出什么
-#/–progress-bar 用进度条显示当前的传送状态
-f, –fail 不显示 连接失败时HTTP错误信息,只显示抓取错误
-R/–remote-time 在本地生成文件时,保留远程文件时间
-u, –user user:password 使用帐户,密码 例如 admin:password
-l, –list-only 只列出FTP目录的名称 (F)
-i, –include 显示内容的同时显示response的header (H/F)
-X, –request [GET|POST|PUT|DELETE|…] 使用指定的 http method 例如 -X POST
-T, –upload-file 上传文件
-b, –cookie cookie 文件 或者 字符串 (H)
-A, –user-agent user-agent设置 (H)
-d, –data 设定 http body 默认使用 content-type application/x-www-form-urlencoded (H)
-G, –get 使用 HTTP GET 方法发送 -d 数据 (H) 如果不加-G参数使用-d,就是一个post请求。
-e, –referer 设定 referer (H) 有的网站会判断,请求来源地址,比如防盗链
-H, –header
-F, –form <name=string> 模拟 HTTP 表单数据提交 multipart POST (H)