当在PHP中发布textarea时,为什么_POST有时会为空

时间:2022-10-06 10:18:28

PHP 4.4 and PHP 5.2.3 under Apache 2.2.4 on ubuntu.

ubuntu上Apache 2.2.4下的PHP 4.4和PHP 5.2.3。

I am running Moodle 1.5.3 and have recently had a problem when updating a course. The $_POST variable is empty but only if a lot of text was entered into the textarea on the form. If only a short text is entered it works fine.

我正在运行Moodle 1.5.3并且最近在更新课程时遇到了问题。 $ _POST变量为空,但前提是在表单上的textarea中输入了大量文本。如果只输入一个短文本,它可以正常工作。

I have increased the post_max_size from 8M to 200M and increased the memory_limit to 256M but this has not helped. I have doubled the LimitRequestFieldSize and LimitRequestLine to 16380 and set LimitRequestBody to 0 with no improvement.

我已将post_max_size从8M增加到200M并将memory_limit增加到256M,但这没有帮助。我已将LimitRequestFieldSize和LimitRequestLine加倍到16380并将LimitRequestBody设置为0而没有任何改进。

I have googled for an answer but have been unable to find one.

我已经google了一个答案,但一直找不到答案。

HTTP Headers on firefox shows the content size of 3816 with the correct data, so its just not getting to $_POST.

firefox上的HTTP标头使用正确的数据显示内容大小为3816,因此它只是没有达到$ _POST。

The system was running fine until a few weeks ago. The only change was to /etc/hosts to correct a HELO issue with the exim4 email server.

该系统运行良好,直到几周前。唯一的变化是/ etc / hosts来纠正exim4电子邮件服务器的HELO问题。

I can replicate the issue on a development machine that has exim4 not running so I think it is just coincidence.

我可以在exim4没有运行的开发机器上复制这个问题所以我认为这只是巧合。

Thanks for your assistance.

谢谢你的协助。

5 个解决方案

#1


1  

Could it be not the size related of the post, but how long the line is before a new line. If they use the Moodle WYSIWYG view the html would just get put into one line with no breaks. If you go into html and hit return around every 1000 characters does it work?

它可能不是与帖子相关的大小,而是该行在新行之前的持续时间。如果他们使用Moodle WYSIWYG视图,那么html将被放入一行而不会中断。如果你进入html并且每1000个字符左右返回它是否有效?

#2


2  

I don't know enough to really provide a useful answer so the following is more a well-educated guess (at least I hope so).

我不知道真的提供一个有用的答案,所以以下是一个受过良好教育的猜测(至少我希望如此)。

First, you should debug the entire request, either by access_log or for example through firebug. (Good to have Firebug anyway.) To me your problem sounds like a redirect happens in between. I give you an example:

首先,您应该通过access_log或通过firebug调试整个请求。 (无论如何都有Firebug很好。)对我来说,你的问题听起来像是在两者之间发生重定向。我举个例子:

Assume this is your structure:

假设这是你的结构:

/form.php
/directory/index.php

This is your form:

这是你的表格:

<form action="/directory" method="post">
...
</form>

Problem in this case is, that even though /directory is a valid url, Apache will redirect you one more time to /directory/, thus you are loosing your payload (what is supposed to be in $_POST).

在这种情况下的问题是,即使/ directory是一个有效的URL,Apache也会再次将你重定向到/ directory /,因此你将丢失你的有效负载(应该在$ _POST中)。

#3


1  

What is the enctype of the form? Could be that it limits the ammount of data send through the form.

表格的enctype是什么?可能是它限制了通过表单发送的数据量。

You might also want to check the incoming raw $_POST data with:

您可能还想检查传入的原始$ _POST数据:

file_get_contents('php://input');

To make sure their is actually data send. Got these suggestions here.

确保它们实际上是数据发送。这里有这些建议。

#4


0  

It sounds like an Apache or Apache/PHP integration problem. If $_POST is empty it would hint that the http server is not giving the POST information to PHP. If I were you I'd investigate the Apache configuration.

这听起来像是Apache或Apache / PHP集成问题。如果$ _POST为空,则会暗示http服务器没有向PHP提供POST信息。如果我是你,我会调查Apache配置。

#5


0  

This is obvious, but did you /etc/init.d/apache2 restart ?

这很明显,但你/etc/init.d/apache2重启了吗?

Also, the error_log file should show some information about whether the post size exceeded the set limit. Consider increasing your verbosity for troubleshooting the issue

此外,error_log文件应显示有关帖子大小是否超出设置限制的一些信息。考虑增加详细程度来解决问题

#1


1  

Could it be not the size related of the post, but how long the line is before a new line. If they use the Moodle WYSIWYG view the html would just get put into one line with no breaks. If you go into html and hit return around every 1000 characters does it work?

它可能不是与帖子相关的大小,而是该行在新行之前的持续时间。如果他们使用Moodle WYSIWYG视图,那么html将被放入一行而不会中断。如果你进入html并且每1000个字符左右返回它是否有效?

#2


2  

I don't know enough to really provide a useful answer so the following is more a well-educated guess (at least I hope so).

我不知道真的提供一个有用的答案,所以以下是一个受过良好教育的猜测(至少我希望如此)。

First, you should debug the entire request, either by access_log or for example through firebug. (Good to have Firebug anyway.) To me your problem sounds like a redirect happens in between. I give you an example:

首先,您应该通过access_log或通过firebug调试整个请求。 (无论如何都有Firebug很好。)对我来说,你的问题听起来像是在两者之间发生重定向。我举个例子:

Assume this is your structure:

假设这是你的结构:

/form.php
/directory/index.php

This is your form:

这是你的表格:

<form action="/directory" method="post">
...
</form>

Problem in this case is, that even though /directory is a valid url, Apache will redirect you one more time to /directory/, thus you are loosing your payload (what is supposed to be in $_POST).

在这种情况下的问题是,即使/ directory是一个有效的URL,Apache也会再次将你重定向到/ directory /,因此你将丢失你的有效负载(应该在$ _POST中)。

#3


1  

What is the enctype of the form? Could be that it limits the ammount of data send through the form.

表格的enctype是什么?可能是它限制了通过表单发送的数据量。

You might also want to check the incoming raw $_POST data with:

您可能还想检查传入的原始$ _POST数据:

file_get_contents('php://input');

To make sure their is actually data send. Got these suggestions here.

确保它们实际上是数据发送。这里有这些建议。

#4


0  

It sounds like an Apache or Apache/PHP integration problem. If $_POST is empty it would hint that the http server is not giving the POST information to PHP. If I were you I'd investigate the Apache configuration.

这听起来像是Apache或Apache / PHP集成问题。如果$ _POST为空,则会暗示http服务器没有向PHP提供POST信息。如果我是你,我会调查Apache配置。

#5


0  

This is obvious, but did you /etc/init.d/apache2 restart ?

这很明显,但你/etc/init.d/apache2重启了吗?

Also, the error_log file should show some information about whether the post size exceeded the set limit. Consider increasing your verbosity for troubleshooting the issue

此外,error_log文件应显示有关帖子大小是否超出设置限制的一些信息。考虑增加详细程度来解决问题