curl - curl的--upload-file是发布请求吗?

标签 curl post

我对curl的“--upload-file”参数有些困惑。手册页仅指出其“将指定的本地文件传输到远程URL”。

这是发帖请求吗?如果不是,那么它是什么?在实际的HTML5客户端应用程序中会是什么样?

最佳答案

这是一个PUT请求。

manual(对于-upload-file,-T为单点划线):

HTTP Upload all data on stdin to a specified HTTP site:

curl -T - http://www.upload.com/myfile

Note that the HTTP server must have been configured to accept PUT before this can be done successfully. For other ways to do HTTP data upload, see the POST section below.



来自curl Documentation的更多信息:

4.4 File Upload POST

Back in late 1995 they defined an additional way to post data over HTTP. It is documented in the RFC 1867, why this method sometimes is referred to as RFC1867-posting.

This method is mainly designed to better support file uploads. A form that allows a user to upload a file could be written like this in HTML:

<form method="POST" enctype='multipart/form-data' action="upload.cgi">

 <input type=file name=upload>
 <input type=submit name=press value="OK">
</form>

This clearly shows that the Content-Type about to be sent is multipart/form-data.

To post to a form like this with curl, you enter a command line like:

curl --form upload=@localfilename --form press=OK [URL]

关于curl - curl的--upload-file是发布请求吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40691850/

相关文章:

c# - C# 中带标志的 cURL 调用

c - 在 C 中使用 Curl 不支持的协议(protocol)

php - Paypal 访问 - SSL 证书 : unable to get local issuer certificate

php - 从 ASP 应用程序接收 PHP 中的 POST 数据

java - android retrofit post request - 从正文中排除字段

PHP curl_exec 返回以空格分隔的 HTTP/1.1 100 Continue 和 HTTP/1.1 200 OK

linux - 如何在 Curl 字符串中使用公历时间戳

Javascript 如何从我的网络应用程序中隐藏一个功能(通过使用 php?)

php - 拉拉维尔 : MethodNotAllowedHttpException only on production server

iphone - 发布数据但获取方法 json -ios