Skip to content

Instantly share code, notes, and snippets.

@77web
Created January 24, 2024 12:19
Show Gist options
  • Save 77web/8413031d999de4b634bf8b269103e84c to your computer and use it in GitHub Desktop.
Save 77web/8413031d999de4b634bf8b269103e84c to your computer and use it in GitHub Desktop.
handling form submission in PHP without $_FILES, $_POST(#phpstudyでymfuruyaさんが発表された内容を試したもの)

$_POST, $_FILES を使わないやつ

php -S 127.0.0.1:8080 -t ./ -c php.ini
enable_post_data_reading=Off
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$fp = fopen('php://input', 'r');
$content = fread($fp, 1024);
fclose($fp);
var_dump($content);
}
?>
<form action="test.php" enctype="multipart/form-data" method="post">
<input type="text" name="mytext" value="test text" />
<input type="file" name="myfile" />
<button type="submit">submit!</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment