开发者

cakephp behavior validation

开发者_StackOverflow

I create some Behavior for uploading files... I check rule in Model by methods in Behavior - it's works fine, but i must check is file uploaded (php function: copy() or is_uploaded_file();) and I would like send message to view about this error. How do this?


In your behavior, assuming that you inject the path to the file into the record as 'filename':

function beforeValidate() {
    if(!is_file_uploaded($this->data[$this->alias]['filename'])) {
        $this->invalidate('filename');
    }
    return true;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜