开发者

file upload validation in kohana 3.1 not working

开发者 https://www.devze.com 2023-04-04 21:06 出处:网络
I am stuck with file upload validation in Kohana 3.1. Though the Upload::not_empty function returning false. I am still getting true from ch开发者_JAVA百科eck() function.

I am stuck with file upload validation in Kohana 3.1. Though the Upload::not_empty function returning false. I am still getting true from ch开发者_JAVA百科eck() function.

Here is my code

$validator = Validation::factory($this->request->post())
        ->rule('name', 'Upload::not_empty', array(':files'))
        ->bind(':files',$_FILES['name']);

var_dump($validator->check());

Above the name is the name of the file field.


I solved this by combining $_POST and $_FILES as suggested by awellis in this thread.

Basically the value of field name was not passed in Validation::factory so the below code in Kohana_Validation's check() function was not returning the error.

// Ignore return values from rules when the field is empty
if ( ! in_array($rule, $this->_empty_rules) AND ! Valid::not_empty($value))
    continue;
0

精彩评论

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

关注公众号