views:

1100

answers:

1

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--

Thanks in advance! /Robert

+2  A: 

The Content-Disposition header has a name argument that has the control name. There should be one after each --sub_boundary

--sub_boundary
Content-Disposition: form-data; name="mycontrol"

I almost forgot: If the field is a file control, there's also a filename field and a Content-Type header

--sub_boundary
Content-Disposition: form-data; name="mycontrol"; filename="file1.xml"
Content-Type: application/xml;

and if the file is not text, you also need

Content-Transfer-Encoding: binary
R. Bemrose
Perfect explanation. Cheers!
sharkin