curl
是一个文件传输工具,可以上传也可以下载,支持 HTTP
、HTTPS
、FTP
等市面上常见的协议。后端开发者经常用它来测试 web
接口。
语法格式:chroot [参数]
常用参数:
示例
# 获取网站源码
curl https://xugaoxiang.com
# 下载文件
curl -O https://xugaoxiang.com/download/test.jpg
# post上传文件
curl -F ‘data=@path/to/local/file’ UPLOAD_ADDRESS
# 以特定key参数上传文件
curl -F 'longjing=@/home/xugaoxiang/test.jpg' http://192.168.1.99:8888/uploadImageFile
#同时上传多个文件
curl -F 'fileX=@/path/to/fileX' -F 'fileY=@/path/to/fileY' ... http://localhost/upload