私は現在、HttpRequestとHttpResponseの2つのクラスをコーディングしています。 私自身のHTTPクラスをコーディングしたい。PHP HTTPリクエストコンテンツ生データenctype = multipart/form-data
enctype = multipart/form-dataのフォームを使用するPOSTメソッドで問題が発生しました。リクエストの内容を取得できません。
長いリサーチと検索の結果、file_get_contents("php://input")
を使用してリクエスト内容を取得する必要があることがわかりました。 私はそれをテストするとき、私は空の文字列var_dump(file_get_contents("php://input"))
を持っています。
私はserver/php設定にアクセスできません。
私は次のコードでテストしています:
<?php
$input = file_get_contents('php://input');
var_dump($input);
?>
<html>
<body>
<form action="./" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="text" name="namen" id="nameid" /><br/>
<input type="file" name="file" id="file"><br>
<input type="file" name="file2" id="file2"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
そして提出した後、私はこの結果を持っている:string(0) ""
を。 enctype = "multipart/form-data"フォームではphp://入力が機能しないので、明らかです。
-----------------------------19972703421793859182225487886
Content-Disposition: form-data; name="namen"
ds
-----------------------------19972703421793859182225487886
Content-Disposition: form-data; name="file"; filename="toto.xml"
Content-Type: text/xml
<?xml version="1.0" encoding="UTF-8"?>
<Toto></Toto>
-----------------------------19972703421793859182225487886
Content-Disposition: form-data; name="file2"; filename=""
Content-Type: application/octet-stream
-----------------------------19972703421793859182225487886
Content-Disposition: form-data; name="submit"
Submit
-----------------------------19972703421793859182225487886--
は、それがどんなリクエストメソッドのために働く方法です:
私のような何かをしたいのですが?または私は間違っていますか?
私はちょうど言ってみたい:私はばかです。ありがとう;) – RaphyTheGeek