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;
加载中,请稍侯......
精彩评论