代码之家  ›  专栏  ›  技术社区  ›  kicaj

用CakePHP归档的表单

  •  0
  • kicaj  · 技术社区  · 16 年前

    如何在beforeSave()中获取字段类型文件的名称?

    1 回复  |  直到 16 年前
        1
  •  2
  •   deceze    16 年前

    好吧,那显然取决于你给它取什么名字。如果未知,只需在数据数组中循环,然后选择一个看起来像文件数组的数组:

    foreach ($this->data[$this->alias] as $field => $contents) {
        if (isset($contents['tmp_name'])) {
            // This is the $field you're looking for
        }
    }