2011-09-15 46 views
0

我在Kohana 3.1中卡住了文件上传验证。虽然Upload::not_empty函数返回false。我仍然从check()功能true在kohana 3.1中的文件上传验证3.1不起作用

这里是我的代码

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

var_dump($validator->check()); 

以上的name名称的文件场

回答

1

我通过结合$_POST$_FILES解决了这个问题,如awellis在this线程中所建议的。

基本上字段name的值在Validation::factory未通过,以便下面的代码在Kohana_Validationcheck()函数不返回该错误。

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