【问题标题】:Partial data in $_FILES variable$_FILES 变量中的部分数据
【发布时间】:2019-07-06 00:03:46
【问题描述】:

我们有一个管理屏幕,用户可以在其中编辑大量数据,此外还有几十个文件类型的输入。

在 PHP 中,每个文件输入都被注入到一个名为 $_FILES 的超全局变量中。

在我的本地开发环境中,一切正常, 问题是在暂存时我们得到的数据是不完整的。

如果我在暂存和本地保存相同的数据,我只能在本地获得完整数据,当用户尝试上传图像时,我什至在 $_FILES 变量中都看不到它。

p>

所以我的问题是,在 staging 中导致此问题的限制是什么?

我有或多或少相同的 php.ini 设置(max_post_size、max_upload_size 等),但我无权编辑暂存中的设置。

暂存规范

  • 服务器版本:Apache/2.2.15
  • PHP 5.3.29
  • Akamai CDN

编辑

$_FILES 输出 Jon Stirling 的请求: 我已将其编码为 JSON,因此更具可读性。

暂存输出:

{
  "user_guide": {
    "name": "",
    "type": "",
    "tmp_name": "",
    "error": 4,
    "size": 0
  },
  "instructionsData": {
    "name": {
      "102": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1395": {
            "image": ""
          },
          "1398": {
            "image": ""
          },
          "1401": {
            "image": ""
          },
          "1404": {
            "image": ""
          }
        }
      },
      "103": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1405": {
            "image": ""
          },
          "1408": {
            "image": ""
          },
          "1411": {
            "image": ""
          },
          "1414": {
            "image": ""
          },
          "1417": {
            "image": ""
          },
          "1420": {
            "image": ""
          },
          "1423": {
            "image": ""
          },
          "1426": {
            "image": ""
          }
        }
      },
      "105": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1428": {
            "image": ""
          }
        }
      }
    },
    "type": {
      "102": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1395": {
            "image": ""
          },
          "1398": {
            "image": ""
          },
          "1401": {
            "image": ""
          },
          "1404": {
            "image": ""
          }
        }
      },
      "103": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1405": {
            "image": ""
          },
          "1408": {
            "image": ""
          },
          "1411": {
            "image": ""
          },
          "1414": {
            "image": ""
          },
          "1417": {
            "image": ""
          },
          "1420": {
            "image": ""
          },
          "1423": {
            "image": ""
          },
          "1426": {
            "image": ""
          }
        }
      },
      "105": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1428": {
            "image": ""
          }
        }
      }
    },
    "tmp_name": {
      "102": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1395": {
            "image": ""
          },
          "1398": {
            "image": ""
          },
          "1401": {
            "image": ""
          },
          "1404": {
            "image": ""
          }
        }
      },
      "103": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1405": {
            "image": ""
          },
          "1408": {
            "image": ""
          },
          "1411": {
            "image": ""
          },
          "1414": {
            "image": ""
          },
          "1417": {
            "image": ""
          },
          "1420": {
            "image": ""
          },
          "1423": {
            "image": ""
          },
          "1426": {
            "image": ""
          }
        }
      },
      "105": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1428": {
            "image": ""
          }
        }
      }
    },
    "error": {
      "102": {
        "icon": 4,
        "icon_inverted": 4,
        "instructionData": {
          "1395": {
            "image": 4
          },
          "1398": {
            "image": 4
          },
          "1401": {
            "image": 4
          },
          "1404": {
            "image": 4
          }
        }
      },
      "103": {
        "icon": 4,
        "icon_inverted": 4,
        "instructionData": {
          "1405": {
            "image": 4
          },
          "1408": {
            "image": 4
          },
          "1411": {
            "image": 4
          },
          "1414": {
            "image": 4
          },
          "1417": {
            "image": 4
          },
          "1420": {
            "image": 4
          },
          "1423": {
            "image": 4
          },
          "1426": {
            "image": 4
          }
        }
      },
      "105": {
        "icon": 4,
        "icon_inverted": 4,
        "instructionData": {
          "1428": {
            "image": 4
          }
        }
      }
    },
    "size": {
      "102": {
        "icon": 0,
        "icon_inverted": 0,
        "instructionData": {
          "1395": {
            "image": 0
          },
          "1398": {
            "image": 0
          },
          "1401": {
            "image": 0
          },
          "1404": {
            "image": 0
          }
        }
      },
      "103": {
        "icon": 0,
        "icon_inverted": 0,
        "instructionData": {
          "1405": {
            "image": 0
          },
          "1408": {
            "image": 0
          },
          "1411": {
            "image": 0
          },
          "1414": {
            "image": 0
          },
          "1417": {
            "image": 0
          },
          "1420": {
            "image": 0
          },
          "1423": {
            "image": 0
          },
          "1426": {
            "image": 0
          }
        }
      },
      "105": {
        "icon": 0,
        "icon_inverted": 0,
        "instructionData": {
          "1428": {
            "image": 0
          }
        }
      }
    }
  }
}

本地输出:

{
  "user_guide": {
    "name": "",
    "type": "",
    "tmp_name": "",
    "error": 4,
    "size": 0
  },
  "instructionsData": {
    "name": {
      "102": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1395": {
            "image": ""
          },
          "1398": {
            "image": ""
          },
          "1401": {
            "image": ""
          },
          "1404": {
            "image": ""
          }
        }
      },
      "103": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1405": {
            "image": ""
          },
          "1408": {
            "image": ""
          },
          "1411": {
            "image": ""
          },
          "1414": {
            "image": ""
          },
          "1417": {
            "image": ""
          },
          "1420": {
            "image": ""
          },
          "1423": {
            "image": ""
          },
          "1426": {
            "image": ""
          }
        }
      },
      "105": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1428": {
            "image": ""
          },
          "1431": {
            "image": ""
          },
          "1434": {
            "image": ""
          },
          "1437": {
            "image": ""
          }
        }
      },
      "106": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1438": {
            "image": ""
          },
          "1441": {
            "image": ""
          },
          "1444": {
            "image": ""
          }
        }
      },
      "109": {
        "icon": "",
        "icon_inverted": "",
        "instructionData": {
          "1447": {
            "image": ""
          },
          "1450": {
            "image": ""
          },
          "1453": {
            "image": ""
          },
          "1456": {
            "image": ""
          },
          "1459": {
            "image": ""
          },
          "1462": {
            "image": ""
          },
          "1465": {
            "image": ""
          },
          "1468": {
            "image": ""
          },
          "1471": {
            "image": ""
          },
          "1474": {
            "image": ""
          },
          "1477": {
            "image": ""
          },
          "1480": {
            "image": ""
          },
          "1483": {
            "image": ""
          },
          "1486": {
            "image": ""
          },
          "1489": {
            "image": ""
          },
          "1492": {
            "image": ""
          },
          "1495": {
            "image": ""
          },
          "1498": {
            "image": ""
          },
          "1501": {
            "image": ""
          },
          "1504": {
            "image": ""
          },
          "1507": {
            "image": ""
          }
        }
      },
      ....

【问题讨论】:

  • 不确定“$_FILES 中的部分数据”是什么样的。你能告诉我们吗?
  • "PHP 5.3.29" — It's been four and a half years since PHP 5.3 got a security update。停止使用它!使用实际支持的东西。
  • @JonStirling 我添加了一个示例
  • @Quentin 我同意,这不是我的选择,我为一个大客户工作,我正在努力让他升级
  • 这不是 $_FILES 输出。你检查error 键入$_FILES 吗?

标签: php apache file-upload


【解决方案1】:

我发现 Staging 中有一个名为 suhosin 的模块,显然它有更多的安全限制和限制。

要找到我添加到php.ini的问题:

suhosin.simulation = 1
suhosin.log.file = 511
suhosin.log.file.name = /tmp/suhosin-alert.log

这导致我出现错误ALERT-SIMULATION - configured fileupload limit exceeded - file dropped,经过研究我不得不更新php.ini中的这些属性:

max_file_uploads = 300
suhosin.upload.max_uploads=300

然后所有的数据都正确出现了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多