使用什么 HTTP 标头来设置表单字段名称(multipart/form-data)
我将原始 HTTP 请求传递到 apache 服务器(由 PHP 接收)。 该请求的类型为 multipart/form-data,即与提交 HTML 表单时使用的 MIME 类型相同。 但是,我不确定使用什么 HTTP 标头来设置表单字段名称(我只是假设它是定义此名称的标头,不知道它还可能是什么),然后可以在 PHP 中使用它来访问$_GET 或 $_FILES 中的字段。
HTTP 请求可能如下所示:
Content-type: multipart/form-data;boundary=main_boundary
--main_boundary
Content-type: text/xml
<?xml version='1.0'?>
<content>
Some content goes here
</content>
--main_boundary
Content-type: multipart/mixed;boundary=sub_boundary
--sub_boundary
Content-type: application/octet-stream
File A contents
--sub_boundary
Content-type: application/octet-stream
File B contents
--sub_boundary
--main_boundary--
I'm passing raw HTTP requests to an apache server (received by PHP). The request is of type multipart/form-data, i.e. the same MIME type used when submitting HTML forms.
However, I'm not sure what HTTP header to use for setting the form field name (I'm just assuming it's a header defining this, don't know what else it could be) which then can be used in PHP to access the field in $_GET or $_FILES.
The HTTP request might look something like this:
Content-type: multipart/form-data;boundary=main_boundary
--main_boundary
Content-type: text/xml
<?xml version='1.0'?>
<content>
Some content goes here
</content>
--main_boundary
Content-type: multipart/mixed;boundary=sub_boundary
--sub_boundary
Content-type: application/octet-stream
File A contents
--sub_boundary
Content-type: application/octet-stream
File B contents
--sub_boundary
--main_boundary--
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Content-Disposition 标头有一个包含控件名称的名称参数。 每个后面应该有一个 --sub_boundary
我差点忘了:如果该字段是文件控件,则还有一个文件名字段和一个 Content-Type 标头
,如果文件不是文本,则还需要
The Content-Disposition header has a name argument that has the control name. There should be one after each --sub_boundary
I almost forgot: If the field is a file control, there's also a filename field and a Content-Type header
and if the file is not text, you also need