开发者

Form with file filed in CakePHP

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜