file_get_contents("php://input")의 사용법
php://input 。 POST , php://input $HTTP_RAW_POST_DATA, php.ini 。 , $HTTP_RAW_POST_DATA , always_populate_raw_post_data 。 enctype="multipart/form-data" php://input 。
1, php://input http entity body , Content-Length , POST GET 。 , GET ,http request entity body 。
2,php://input $HTTP_RAW_POST_DATA , Content-Type multipart/form-data 。
1,Coentent-Type application/x-www-data-urlencoded multipart/form-data ,PHP http $_POST
2,PHP Content-Type , http $HTTP_RAW_POST_DATA
3, Coentent-Type multipart/form-data ,PHP http php://input, 。 , Coentent-Length 。
4, Content-Type application/x-www-data-urlencoded ,php://input $_POST 。
5,php://input $HTTP_RAW_POST_DATA , php://input $HTTP_RAW_POST_DATA , php.ini
6,PHP PATH query_path , $_GET。 ,GET http ,body 。
1.php file_get_contents("php://input") $HTTP_RAW_POST_DATA xml
:
getXML.php;// XML
php
$xmldata = file_get_contents("php://input");
$data = (array)simplexml_load_string($xmldata);
$data xml , php xml
sendXML.php
php
$xml = 'xmldata ';// xml
$url = 'http://localhost/test/getXML.php';// XML
$header = 'Content-type: text/xml';// content-type xml
$ch = curl_init(); // curl
curl_setopt($ch, CURLOPT_URL, $url);//
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);// HTTP
curl_setopt($ch, CURLOPT_POST, 1);// POST
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);//POST
$response = curl_exec($ch);//
if(curl_errno($ch)){//
print curl_error($ch);
}
curl_close($ch); // curl
echo $response;//
2.
php
//@file phpinput_post.php
$data=file_get_contents('btn.png');
$http_entity_body = $data;
$http_entity_type = 'application/x-www-form-urlencoded';
$http_entity_length = strlen($http_entity_body);
$host = '127.0.0.1';
$port = 80;
$path = '/image.php';
$fp = fsockopen($host, $port, $error_no, $error_desc, 30);
if ($fp){
fputs($fp, "POST {$path} HTTP/1.1\r
");
fputs($fp, "Host: {$host}\r
");
fputs($fp, "Content-Type: {$http_entity_type}\r
");
fputs($fp, "Content-Length: {$http_entity_length}\r
");
fputs($fp, "Connection: close\r
\r
");
fputs($fp, $http_entity_body . "\r
\r
");
while (!feof($fp)) {
$d .= fgets($fp, 4096);
}
fclose($fp);
echo $d;
}
php
/**
*Recieve image data
**/
error_reporting(E_ALL);
function get_contents() {
$xmlstr= file_get_contents("php://input");
$filename=time().'.png';
if(file_put_contents($filename,$xmlstr)){
echo 'success';
}else{
echo 'failed';
}
}
get_contents();
3. HTTP
/**
* HTTP
* @return string
*/
function get_http_raw() {
$raw = '';
// (1)
$raw .= $_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' '.$_SERVER['SERVER_PROTOCOL']."\r
";
// (2) Headers
foreach($_SERVER as $key => $value) {
if(substr($key, 0, 5) === 'HTTP_') {
$key = substr($key, 5);
$key = str_replace('_', '-', $key);
$raw .= $key.': '.$value."\r
";
}
}
// (3)
$raw .= "\r
";
// (4) Body
$raw .= file_get_contents('php://input');
return $raw;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Laravel - 변환된 유효성 검사 규칙으로 API 요청 제공동적 콘텐츠를 위해 API를 통해 Laravel CMS에 연결하는 모바일 앱(또는 웹사이트) 구축을 고려하십시오. 이제 앱은 CMS에서 번역된 콘텐츠를 받을 것으로 예상되는 다국어 앱이 될 수 있습니다. 일반적으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.