用curl命令上传文件和以post方式发请求

来源:互联网 发布:mac ftp 看不到文件夹 编辑:程序博客网 时间:2024/06/05 14:54

To upload a file via curl:

curl http://api.example.com/profile -F "image=@profile.jpg"
In php this will give you the profile.jpg in the $_FILES['image'], now to add additional field values you just add additional -F arguments like this:
curl http://api.example.com/profile -F "image=@profile.jpg" -F "phone=123456789"
To post simple field/value:
curl http://api.example.com/profile -d "phone=123456789&name=Hwei"
0 0