curl的--upload-file是发布请求吗? [英] Is curl's --upload-file a post request?

查看:990
本文介绍了curl的--upload-file是发布请求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm a little bit confused about curl's "--upload-file" argument. The man-page just states that it "transfers the specified local file to the remote URL.".

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

Is this a post request? If no, what is it then and how would this look like in an actual HTML5 client app?

推荐答案

这是一个PUT请求.

摘录自手册(-T为--upload-的单点划线-文件):

From the manual (-T is single-dashed for --upload-file):

HTTP 将stdin上的所有数据上传到指定的HTTP站点:

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

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

请注意,必须先将HTTP服务器配置为接受PUT,然后才能成功完成此操作. 有关进行HTTP数据上传的其他方法,请参见下面的POST部分.

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文档中的其他信息:

4.4文件上传POST

4.4 File Upload POST

早在1995年末,他们定义了另一种方法来发布数据 HTTP.在RFC 1867中有记录,为什么有时使用这种方法 称为RFC1867发布.

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.

此方法主要用于更好地支持文件上传.表单 允许用户上传文件的代码可以这样写 HTML:

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>

这清楚地表明即将发送的Content-Type为 multipart/form-data.

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

要使用curl张贴到这样的表单,请输入以下命令行:

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

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

这篇关于curl的--upload-file是发布请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆