Zend_File_Transfer中的单个文件的跳过验证

|| 为了创建公司,我上传了5张图片以及.csv文件。我已经使用了以下zend验证器
$upload = new Zend_File_Transfer();
        $upload->addValidator(\'Count\', false, array(\'min\' =>1, \'max\' => 6))
               ->addValidator(\'Size\', false, array(\'max\' => \'1Mb\'))
               ->addValidator(\'ImageSize\', false, array(\'minwidth\' => 50,
                                                        \'maxwidth\' => 1000,
                                                        \'minheight\' => 50,
                                                        \'maxheight\' => 1000));
当我上传CSV时,出现错误,提示未检测到ImageSize。有什么方法可以跳过.csv文件的ImageSize验证器?     
已邀请:
        在此示例中,验证第一个图像的高度为435px乘以175px,其余所有其余图像的高度为200px乘以200px。
$targetPath = $this->registry->DOC_ROOT.\'/public/uploads/images/campersite_user_photo/\';

            if(!is_dir($targetPath))
            {
                mkdir($targetPath,\'0777\');
            }

            $adapter->setDestination($targetPath);

            $first = true;
            $filecheck = \'\';

            if(isset($asAdminVal[\'admin_role_id\']) && ($asAdminVal[\'admin_role_id\'] == \'1\' || $asAdminVal[\'admin_role_id\'] == \'2\'))
            {
                $photoCount = Model_TblCampersiteUserPhotos::getCamperPhotoCount($this->view->snCampId);

                if($photoCount == 0)
                {
                    $j = 1;

                    foreach ($adapter->getFileInfo() as $fields => $info) 
                    {
                        if($info[\'name\'] != \'\' && $first == true)
                        {
                            $filecheck = $fields;
                        }

                        if($filecheck != \'\' && $first == true)
                        {
                            $form->photo_path->addValidator(\'ImageSize\', false,array(\'minwidth\' => 435,\'minheight\' => 175,\'messages\' => array(\'fileImageSizeWidthTooSmall\' => $this->translate->_(\'msg_camper_banner_image_file_too_width_height_less\'),\'fileImageSizeHeightTooSmall\' => $this->translate->_(\'msg_camper_banner_image_file_too_width_height_less\'))),$fields);
                            $first = false;
                        }
                        else
                        {
                            $form->photo_path->addValidator(\'ImageSize\', false,array(\'minwidth\' => 200,\'minheight\' => 200,\'messages\' => array(\'fileImageSizeWidthTooSmall\' => $this->translate->_(\'msg_file_too_small\'),\'fileImageSizeHeightTooSmall\' => $this->translate->_(\'msg_file_too_small\'))),$fields);
                        }
                        $fileInfo[$j] = $info;
                        $j++;
                    }
                }
                else
                {
                    $j = 1;
                    foreach ($adapter->getFileInfo() as $fields => $info) 
                    {
                        $form->photo_path->addValidator(\'ImageSize\', false,array(\'minwidth\' => 200,\'minheight\' => 200,\'messages\' => array(\'fileImageSizeWidthTooSmall\' => $this->translate->_(\'msg_file_too_small\'),\'fileImageSizeHeightTooSmall\' => $this->translate->_(\'msg_file_too_small\'))),$fields);
                        $fileInfo[$j] = $info;
                        $j++;
                    }   
                }
            }
            else
            {
                $j = 1;
                foreach ($adapter->getFileInfo() as $fields => $info) 
                {
                    $form->photo_path->addValidator(\'ImageSize\', false,array(\'minwidth\' => 200,\'minheight\' => 200,\'messages\' => array(\'fileImageSizeWidthTooSmall\' => $this->translate->_(\'msg_file_too_small\'),\'fileImageSizeHeightTooSmall\' => $this->translate->_(\'msg_file_too_small\'))),$fields);
                    $fileInfo[$j] = $info;
                    $j++;                   
                }
            }
要验证表单,请编写以下代码。
if($form->isValid($formData))
{

}
    
        而且我想出了怎么做!
$upload = new Zend_File_Transfer();
    $files = $upload->getFileInfo();
    foreach ($files as $fields => $contents)
    {
        if ($fields!= \'filename6\')  -- Skipping the validation for csv file
        {
            $upload->addValidator(\'Count\', false, array(\'min\' =>1, \'max\' => 6),$fields)
                   ->addValidator(\'Size\', false, array(\'max\' => \'1Mb\'),$fields)
                   ->addValidator(\'ImageSize\', false, array(\'minwidth\' => 50,
                                                            \'maxwidth\' => 1000,
                                                            \'minheight\' => 50,
                                                            \'maxheight\' => 1000),$fields);
        }
        elseif ($fields == \'filename6\') -- To validate only csv file
        {
            $upload->addValidator(\'Extension\', false, \'csv\', $fields)
                   ->addValidator(\'Size\', false, array(\'max\' => \'1Mb\'),$fields);
        }
    }          
    

要回复问题请先登录注册