【问题标题】:Get Element from FILES Array PHP从 FILES 数组 PHP 中获取元素
【发布时间】:2014-03-29 18:17:53
【问题描述】:

好的,这可能非常简单,但我不知道如何从以下数组中获取项目:以下数组来自我的 $_FILES 全局。

array(1) {
  ["test"]=>
  array(5) {
    ["name"]=>
    string(8) "204.docx"
    ["type"]=>
    string(71) "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
    ["tmp_name"]=>
    string(14) "/tmp/php57NIMV"
    ["error"]=>
    int(0)
    ["size"]=>
    int(13249)
  }
}

我的目标只是通过使用类似的东西来获取数据 - echo $_FILES['test']['name'] 但这不起作用。谢谢。

【问题讨论】:

  • 显示您尝试访问该值的代码
  • 如果你 var dump $_FILES['test'] 会有什么结果
  • 就是这样。您在上面看到的是 vardump

标签: php arrays file


【解决方案1】:

有时因为 php.ini 配置

max_file_size
post_max_size

不发送表单中的值。检查你的配置

【讨论】:

  • 也许我没有正确解释。数组工作正常,我要做的就是使用上面的数组回显文件名。
  • 代码如上。我只是想用 php 来回显这个数组中的 name 属性。名称属性/键是“名称”,值是 204.docx。我如何循环或从该数组中获取名称值并将其回显。 $_FILES['test']['name] 是我第一次尝试,但没有返回任何值。
  • $_FILES['test'] 也带回空
  • 当你使用 var_dump($_FILES) 结果是什么?也使用代码 ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1);
猜你喜欢
  • 2011-04-15
  • 1970-01-01
  • 2012-02-11
  • 2014-12-19
  • 2021-11-01
  • 2016-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多