使用 curl 进行 POST 时选择文件名吗?

使用 curl 进行 POST 时选择文件名吗?

我想使用 curl 发布文件上传,并在请求时选择文件名。

这是我现在拥有的卷曲线,它用于上传文件:

curl --form "[email protected]" http://www.website.com/upload

表单字段的名称是通过根据 Chrome 开发工具查看请求来确定的:

POST /upload HTTP/1.1
Host: website.com
Connection: keep-alive
Content-Length: 2346
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://www.website.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQqVYRMJ741ihKEHQ
DNT: 1
Referer: http://www.website.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

Request Payload
------WebKitFormBoundaryQqVYRMJ741ihKEHQ
Content-Disposition: form-data; name="upload_file"; filename="content.txt"
Content-Type: text/plain


------WebKitFormBoundaryQqVYRMJ741ihKEHQ--

我想使用 curl 将文件上传到本地文件系统,但在请求时选择文件名。有没有办法修改请求有效负载中的“文件名”的值?

相关内容