2010-05-01 149 views
0

如何在CakePHP中验证文件上传? 当我写这样的一些:验证文件上传CakePHP

var $validate = array(
    'file' => array(
     'select' => array(
      'rule' => array('selectFile'), 
      'message' => 'There is no file!'), 
     'type' => array(
      'rule' => array('typeFile'), 
      'message' => 'Bad type!'), 
     'size' => array(
      'rule' => array('sizeFile'), 
      'message' => 'Bad with size!')));
只适用于最后一次验证,这里'大小'。 也许你知道解决方案,用于验证包含许多消息的文件吗?加入所需

+0

创建方法选择文件(),typeFile()和sizeFile(),用于测试所有返回false,但顺序为:大小,类型和选择。为什么不按顺序选择,类型和最后尺寸? – kicaj 2010-05-01 16:52:49

回答

0

尝试=真到每个3条规则

+0

我找到了解决办法:http://www.openwritings.net/content/execution-order-multiple-validation-rules – kicaj 2010-05-03 11:19:59