복붙노트

method = "post"enctype = "text / plain"은 호환되지 않습니까?

PHP

method = "post"enctype = "text / plain"은 호환되지 않습니까?

내가 사용할 때

<form method="post" enctype="text/plain" action="proc.php"> 

양식 데이터를 제대로 proc.php 파일로 보낼 수 없습니다. 왜? 문제가 무엇입니까? 왜 내가 게시물과 함께 텍스트 / 일반 인코딩을 사용할 수 없지만 get 메소드와 함께 사용할 수 있습니까?

해결법

  1. ==============================

    1.[수정]

    [수정]

    대답은 PHP가 처리하지 못하기 때문이며 버그가 아닙니다.

    https://bugs.php.net/bug.php?id=33741

    Valid values for enctype in <form> tag are:
    
    application/x-www-form-urlencoded
    multipart/form-data
    

    첫 번째는 기본값이며 두 번째는 파일을 업로드 할 때만 필요합니다.

    @Alohci는 왜 PHP가 $ _POST 배열을 채우지 않고 변수 $ HTTP_RAW_POST_DATA에 값을 저장하는지 설명했습니다.

    text / plain enctype을 잘못 처리 할 수있는 예 :

    file1.php :

    <form method="post" enctype="text/plain" action="file2.php">
    <textarea name="input1">abc
    input2=def</textarea>
    <input name="input2" value="ghi" />
    <input type="submit">
    </form>
    

    file2.php :

    <?php
    print($HTTP_RAW_POST_DATA);
    ?>
    

    결과:

    input1=abc
    input2=def
    input2=ghi
    

    입력 값과 입력 변수를 구별 할 방법이 없습니다. 그것은 될 수 있습니다

    앞에서 언급 한 다른 두 가지 인코딩을 사용할 때 이러한 문제가 없습니다.

    GET과 POST의 차이 :

  2. ==============================

    2.HTML5는 http://dev.w3.org/html5/spec/association-of-controls-and-forms.html#plain-text-form-data 형식으로 텍스트 / 일반 형식으로 제출 된 양식 데이터를 형식화하는 방법을 정의합니다.

    HTML5는 http://dev.w3.org/html5/spec/association-of-controls-and-forms.html#plain-text-form-data 형식으로 텍스트 / 일반 형식으로 제출 된 양식 데이터를 형식화하는 방법을 정의합니다.

    그 섹션의 하단에, 그것은 말한다 :

    따라서 PHP는이를 해석하지 않고 원시 형식으로 만 사용할 수 있습니다. 나에게 그것은 올바른 접근법 인 것 같다.

  3. from https://stackoverflow.com/questions/7628249/method-post-enctype-text-plain-are-not-compatible by cc-by-sa and MIT license