문제

원시 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--
도움이 되었습니까?

해결책

Content-Disposition 헤더에는 컨트롤 이름이 있는 이름 인수가 있습니다.각 --sub_boundary 뒤에 하나씩 있어야 합니다.

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

나는 거의 잊어버렸다:필드가 파일 제어인 경우 파일 이름 필드와 Content-Type 헤더도 있습니다.

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

파일이 텍스트가 아닌 경우에도 필요합니다.

Content-Transfer-Encoding: binary
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top