2011-04-04 59 views
1

下面的代码返回“文件‘’无法读取或不存在”总是:Zend的文件验证器返回错误信息

$filters = array(
    '*' => 'stringTrim' 
); 
$validators = array(
    'image'=> array(
     'allowEmpty' => TRUE, 
     new Zend_Validate_File_ImageSize(array('minheight'=>0,'minwidth'=>0,'maxheight'=>1024,'maxwidth'=>1024)), 
    ) 
); 
$input = new Zend_Filter_Input($filters, $validators); 
$input->setData(array_merge($data, $_FILES)); 
if (!$input->isValid()) { 
    $this->_errors = $input->getMessages(); 
} 

回答

2

文件输入的输入名称必须image。此外,请确保您的表单有enctype="multipart/form-data"$_FILES的格式解释为。

除此之外,我不检测Zend_Validate_File_ImageSize任何代码,可以在$_FILES操作。我认为你必须传递文件的实际路径,例如'image' => $_FILES['image']['tmp_name'](在您的$input->setData()调用中)。

+0

TNX,工作。 $ files ['image'] = $ _FILES ['image'] ['tmp_name'];并使用$文件insteade $ _FILES – 2011-04-04 07:43:41

+0

现在返回允许的最大宽度图像“”应该是“94”,但“128”检测。它应该是图像'图像'的最大允许宽度应该是'94',但是'128'被检测到 – 2011-04-04 07:49:03

+0

不确定这个,可能是一个错误。如果是这样,请将其报告给ZF开发团队。 – Htbaa 2011-04-04 07:58:45