我的Web服务器上突然出现了一个奇怪的问题。我正在将表单发布到PHP,并且有一定数量的输入,$_POST数组是空的,并且输入流似乎没有完全读取。
<?php
var_dump(file_get_contents("php://input"));
print_r($_POST);
?>
<html>
<body>
<form action="form.php" method="POST" enctype="multipart/form-data">
<input type="text" name="blub" value="12345">
<input type="text" name="foo" value="abc">
<input type="text" name="blub1" value="12345">
<input type="text" name="foo1" value="abc">
<input type="text" name="blub2" value="12345">
<input type="text" name="foo2" value="abc">
<input type="text" name="blub3" value="12345">
<input type="text" name="foo3" value="abc">
<input type="text" name="blub4" value="12345">
<input type="text" name="foo4" value="abc">
<input type="text" name="blub5" value="12345">
<input type="text" name="foo5" value="abc">
<input type="text" name="blub6" value="12345">
<input type="text" name="foo6" value="abc">
<input type="submit">
</form>
<form action="form.php" method="POST" enctype="multipart/form-data">
<input type="text" name="blub" value="12345">
<input type="text" name="foo" value="abc">
<input type="text" name="blub1" value="12345">
<input type="text" name="foo1" value="abc">
<input type="text" name="blub2" value="12345">
<input type="text" name="foo2" value="abc">
<input type="text" name="blub3" value="12345">
<input type="text" name="foo3" value="abc">
<input type="text" name="blub4" value="12345">
<input type="text" name="foo4" value="abc">
<input type="text" name="blub5" value="12345">
<input type="text" name="foo5" value="abc">
<input type="text" name="blub6" value="12345">
<input type="text" name="foo6" value="abc">
<input type="text" name="blub7" value="12345">
<input type="text" name="foo7" value="abc">
<input type="submit">
</form>
</body>
</html>
第一个表单工作正常,第二个表单中断,输出如下:
string(118) "daryIaQvu0q5CBO86f9U Content-Disposition: form-data; name="foo7" abc ------WebKitFormBoundaryIaQvu0q5CBO86f9U-- " Array ( )
我不知道代码有任何变化,所以它可能是在一些PHP更新或类似的情况下发生的。
我检查了很多设置,phpinfo设置如下:
Directive Local Value Master Value
always_populate_raw_post_data Off Off
auto_append_file no value no value
auto_prepend_file no value no value
enable_post_data_reading On On
file_uploads On On
max_execution_time 60 60
max_file_uploads 20 20
max_input_nesting_level 200 200
max_input_time 60 60
max_input_vars 1000 1000
memory_limit 128M 128M
output_buffering 4096 4096
output_handler no value no value
post_max_size 128M 128M
upload_max_filesize 128M 128M
variables_order GPCS GPCS
还有什么建议需要检查吗?似乎只能读取固定数量的输入流,因为更改提交值的长度会更改输入流的截断部分。
string(118) "daryIaQvu0q5CBO86f9U Content-Disposition: form-data; name="foo7" abc ------WebKitFormBoundaryIaQvu0q5CBO86f9U-- " Array ( )
问题来了。看看你的语录,有些是结尾,有些不是。你的引号里有引号?!?
我搞不清问题出在哪里。将网站移动到新服务器解决了此问题。谢谢大家,很抱歉我不能发布一个真正的解决方案。