开发者

Form with file filed in CakePHP

开发者 https://www.devze.com 2022-12-28 22:48 出处:网络
How get name of field type file in beforeSave()? I have for开发者_运维技巧m with many file filed, and i must get names of each...Well, that obviously depends on what name you give it. If that\'s unkno

How get name of field type file in beforeSave()? I have for开发者_运维技巧m with many file filed, and i must get names of each...


Well, that obviously depends on what name you give it. If that's unknown, you can simply loop through the data array and pick the one that looks like a file array:

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

精彩评论

暂无评论...
验证码 换一张
取 消