我对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/