草庐IT

php - textarea 偶尔会在 $_POST 中丢失,但 content_length 总是正确的?

coder 2024-04-07 原文

在运行相当活跃的站点的服务器上出现了一个奇怪的错误。

  • 服务器:Apache/2.2.3 (CentOS)
  • PHP:5.2.6
  • 电子加速器 0.9.5.3

在使用多部分表单时,偶尔从文本区域发送的数据会在 $_POST 中丢失

我们知道数据已发送,因为 content_length 显示超过 1K 的合理大小

表单中的所有其他输入字段均已正确接收。

它不是特定于浏览器的,并且发生在 IE/Firefox/Chrome 上。

几乎 99% 的时间都有效,每发布一百个帖子平均只有 1 到 2 次失败。

在极少数情况下,我们能够自己重现它,所以我们知道数据正在发送,只是没有被 apache/php 处理

所有这些设置都已经过检查并且是合理的 在 php.ini 中:

memory_limit
max_input_time
upload_max_file_size
post_max_filesize

在 httpd.conf 中

LimitRequestBody
TimeOut

很想听听其他想法。 我找不到任何已知的 PHP 相关错误。

最佳答案

不确定这是问题所在(不是一个容易猜到的问题 ^^ ),但如果你有 suhoshin安全补丁/扩展,你试过停用它吗?
(我不知道它在 CentOS 上是否默认激活,但考虑到它在 Ubuntu 上,它可能是“不太面向企业的”)

我建议这样做是因为 this bug report ,其中有几个注释,例如:

[30 Oct 2007 11:02am UTC] sbauer at gjl-network dot net

While experiencing this issue, too we found that the cause of this problem was the suhosin patch, wich was - by default - configured to have a max limit for the length of cookie, request, post, get and session vars. E.g. for POST this looks like:

suhosin.post.max_array_depth 100 100 suhosin.post.max_array_index_length 64 64 suhosin.post.max_name_length 64 64 suhosin.post.max_totalname_length
256 256 suhosin.post.max_value_length 65000 65000 suhosin.post.max_vars
200 200

Those derivatives needs to be set to a adequate higher number. E.g. in our case, the problem was, that our POST data was too long (as this seems to be the case for a lot of you here).

So I suggest to check your php.ini or (according to your distribution there often is a suhosin.ini) and correct the above values or set them to 0 to disable it. If those derivatives are not set, default values will be used. You need to check / add: suhosin.post.max_.... suhosin.request.max_... suhosin.get.max_... suhosin.session.max_... suhosin.cookie.max_...

Refer to your phpinfo() where these values should be listed!

和/或:

[13 Nov 2008 4:58pm UTC] keith at tdrnetworks dot com

Regarding the enctype="multipart/form-data" not populating the $_POST vars I found my solution was to disable the Suhosin security module.

Have a go!

还有一条注释说:

[5 Feb 6:49pm UTC] neal dot pressley at yahoo dot com

I was facing the same problem. I had a html form with php scripts in which I was submitting radio buttons or checkboxes. When I post the form, PHP was not finding any post parameters. it was random, some time it was working and some time not. Even I tried with Get, it worked some time and some time not. Then I change ENCTYPE from uppercase to lowercase and it started working prefectly

您的表单/页面 HTML 有效吗?也许,在极少数情况下,不是?


也许这会有所帮助...如果没有,我很想知道这个问题的原因!

关于php - textarea 偶尔会在 $_POST 中丢失,但 content_length 总是正确的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1192055/

有关php - textarea 偶尔会在 $_POST 中丢失,但 content_length 总是正确的?的更多相关文章

  1. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  2. ruby - 如何模拟 Net::HTTP::Post? - 2

    是的,我知道最好使用webmock,但我想知道如何在RSpec中模拟此方法:defmethod_to_testurl=URI.parseurireq=Net::HTTP::Post.newurl.pathres=Net::HTTP.start(url.host,url.port)do|http|http.requestreq,foo:1endresend这是RSpec:let(:uri){'http://example.com'}specify'HTTPcall'dohttp=mock:httpNet::HTTP.stub!(:start).and_yieldhttphttp.shou

  3. ruby-on-rails - rails : How to make a form post to another controller action - 2

    我知道您通常应该在Rails中使用新建/创建和编辑/更新之间的链接,但我有一个情况需要其他东西。无论如何我可以实现同样的连接吗?我有一个模型表单,我希望它发布数据(类似于新View如何发布到创建操作)。这是我的表格prohibitedthisjobfrombeingsaved: 最佳答案 使用:url选项。=form_for@job,:url=>company_path,:html=>{:method=>:post/:put} 关于ruby-on-rails-rails:Howtomak

  4. ruby - 有人可以帮助解释类创建的 post_initialize 回调吗 (Sandi Metz) - 2

    我正在阅读SandiMetz的POODR,并且遇到了一个我不太了解的编码原则。这是代码:classBicycleattr_reader:size,:chain,:tire_sizedefinitialize(args={})@size=args[:size]||1@chain=args[:chain]||2@tire_size=args[:tire_size]||3post_initialize(args)endendclassMountainBike此代码将为其各自的属性输出1,2,3,4,5。我不明白的是查找方法。当一辆山地自行车被实例化时,因为它没有自己的initialize方法

  5. jquery - 我的 jquery AJAX POST 请求无需发送 Authenticity Token (Rails) - 2

    rails中是否有任何规定允许站点的所有AJAXPOST请求在没有authenticity_token的情况下通过?我有一个调用Controller方法的JqueryPOSTajax调用,但我没有在其中放置任何真实性代码,但调用成功。我的ApplicationController确实有'request_forgery_protection'并且我已经改变了config.action_controller.consider_all_requests_local在我的environments/development.rb中为false我还搜索了我的代码以确保我没有重载ajaxSend来发送

  6. ruby - 我如何添加二进制数据来遏制 POST - 2

    我正在尝试使用Curbgem执行以下POST以解析云curl-XPOST\-H"X-Parse-Application-Id:PARSE_APP_ID"\-H"X-Parse-REST-API-Key:PARSE_API_KEY"\-H"Content-Type:image/jpeg"\--data-binary'@myPicture.jpg'\https://api.parse.com/1/files/pic.jpg用这个:curl=Curl::Easy.new("https://api.parse.com/1/files/lion.jpg")curl.multipart_form_

  7. ruby-on-rails - 如何通过 POST 发送多个相同的键/参数? - 2

    如果我必须在一个HTTP请求中发送一堆post参数,所有这些参数都具有相同的名称,我该如何构建要发布的data对象?想象一个带有一些复选框的表单,它们都具有相同的name属性但具有不同的值(如果它们被选中):我想用ruby​​构建它(但它需要根据在表单上选择的内容动态创建):data={"color"=>"red","color"=>"green","color"=>"blue"}然后将数据发送到某个URL:Net::HTTP.post_form(url,data)我无法控制接收端,所以我必须发送它期望接收的参数。怎么办? 最佳答案

  8. ruby-on-rails - Ubuntu 14.04 Rails 丢失文件 - 2

    安装Rails时,一切都很好,但后来,我写道:rails-v和输出:/home/toshiba/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in`require':cannotloadsuchfile--rails/cli(LoadError)from/home/toshiba/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in`r

  9. ruby - HTTP POST 上的 SSL 错误(未知协议(protocol)) - 2

    尝试通过SSL连接到ImgurAPI时出现错误。这是代码和错误:API_URI=URI.parse('https://api.imgur.com')API_PUBLIC_KEY='Client-ID--'ENDPOINTS={:image=>'/3/image',:gallery=>'/3/gallery'}#Public:Uploadanimage##args-Theimagepathfortheimagetoupload#defupload(image_path)http=Net::HTTP.new(API_URI.host)http.use_ssl=truehttp.verify

  10. ruby - 将 ruby​​ 日期转换为字符串而不丢失格式 - 2

    我正在尝试将RubyDate对象转换为字符串。日期格式为:Sun,15Sep2013但是,当我使用#to_s将其转换为字符串时,它会给出以下内容:"2013-09-15"相反,我希望它变成:"Sun,15Sep2013" 最佳答案 使用Date#strftime有很多选择require'date'date=Date.parse("Sun,15Sep2013")#=>#date.strftime("%a,%d%b%Y")#=>"Sun,15Sep2013" 关于ruby-将ruby​​日期

随机推荐