、175px幅と200pxの幅によって200pxの高さのために、他のすべての残りの画像によって435px高さの最初の画像を検証する例を示します。
$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))
{
}
あなたが満足している場合は、これを答えとしてマークしてください。将来的に別の人を助けるかもしれません。 – roufamatic