【问题标题】:cannot retrieve large post data from $_POST无法从 $_POST 检索大型帖子数据
【发布时间】:2015-03-08 03:59:49
【问题描述】:

我有一个奇怪的问题,我试图发布大约 1GB 的数据,但是当我收到数据时,页面/api 会在没有发布数据的情况下执行。 $_POST 是空的,但 file_get_contents("php://input") 不是。我已将我的 php 内存限制设置为 -1 最大帖子大小为 1024M

有什么办法可以解决这个问题吗?这是我的卷曲信息:

Array
(
    url => https://myapi.dev/endpoint.json
    content_type => text/html
    http_code => 200
    header_size => 551
    request_size => 489
    filetime => -1
    ssl_verify_result => 0
    redirect_count => 1
    total_time => 30.591151
    namelookup_time => 0.000337
    connect_time => 0.002641
    pretransfer_time => 0.0056
    size_upload => 736249473
    size_download => 20
    speed_download => 0
    speed_upload => 24067400
    download_content_length => 20
    upload_content_length => 736249473
    starttransfer_time => 0.049208
    redirect_time => 15.965002
    certinfo => Array
        (
        )

    redirect_url => 
)

【问题讨论】:

  • 你用的是什么网络服务器?
  • @LuckyBurger 我正在使用 apache
  • 什么版本的php?
  • @LuckyBurger 发送服务器和接收服务器都使用PHP 5.3.10-1ubuntu3.15 with Suhosin-Patch
  • 嗯嗯,这没有任何意义......我唯一能想到的是 content_type 是错误的

标签: php linux apache post curl


【解决方案1】:

将 php memory limit 设置为 -1 并将 max post size 设置为 1024M 可能还不够。

我也同意@Panama Jack 的观点;如果 php.ini 中的设置全部失败,apache 也可能是一个因素。您可能必须同时考虑两者。但在大多数情况下,这不是问题。这取决于您的配置。

max_execution_time 实际上可能会抛出错误。我建议将您的设置更改为 18000(即 5 小时),这对于 1GB 来说是可以的。

php.ini 设置而言,我建议将它们设置为略高于您预期上传的值。例如,如果您希望上传 1G 文件,则将设置设置为 1536M (1.5G)。这适用于upload_max_filesizepost_max_sizememory_limit;它是这 4 个设置的组合。

【讨论】:

    【解决方案2】:

    在您的php.iniphp_info() 中检查这些:

    post_max_size - http://php.net/post_max_size
    upload_max_filesize - http://php.net/upload_max_filesize
    memory_limit - http://php.net/memory_limit
    

    也检查这些:

    max_execution_time  - http://php.net/manual/en/info.configuration.php#ini.max-execution-time
    set_time_limit - http://php.net/manual/en/function.set-time-limit.php
    

    祝你好运! :-)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-02-03
      • 2023-04-05
      • 1970-01-01
      • 2016-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多