cURL is a command-line utility for transferring data from or to a remote server using one of the supported protocols.
It is installed by default on macOS and most Linux distributions.
- wget http://curl.haxx.se/download/curl-7.19.6.tar.gz
-
- tar -zxvf curl-7.19.6.tar.gz
-
- cd curl-7.19.6
-
- ./configure --prefix=/usr/local/curl
-
- make
-
- make install
无法访问互联网下载的用户,可以在互联网下载好,导入到内网。
curl -X POST [options] [URL]
The -X option specifies which HTTP request method will be used when communicating with the remote server.
下边是文件上传的例子
- # 文件上传
- curl -X POST url -F 'sbbh=A65DADBE166594FA70B622E29C45F935' -F file=@/data/zzzd/reg_record.mp3'
When the -F option is used, curl sends the data using the multipart/form-data Content-Type.
curl -X POST -d 'name=linuxize' -d 'email=linuxize@example.com' https://example.com/contact.php
If the
-doption is used more than once you can merge the data using the&symbol
curl -X POST -d 'name=linuxize&email=linuxize@example.com' https://example.com/contact.php
To set a specific header or Content-Type use the
-Hoption. The following command sets the POST request type toapplication/jsonand sends a JSON object
curl -X POST -H "Content-Type: application/json" -d '{"name": "linuxize", "email": "linuxize@example.com"}' https://example/contact