私のコントローラーでは、関数を使用してサイトのロゴをアップロードしていますが、ロゴ画像の高さが65pxであることを検証したいのですが、これをcakephpに実装するにはどうすればよいですか? ありがとう
if ($this->request->is('post')||$this->request->is('put')) {
if (!empty($this->data['GlobalAdminSetting']['site_logo']['name']) && is_uploaded_file($this->data['GlobalAdminSetting']['site_logo']['tmp_name'])) {
$allowedType = array('image/jpeg', 'image/pjpeg', 'image/jpeg', 'image/pjpeg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
if (!is_dir(APP . DS . WEBROOT_DIR . DS . 'siteImg/')) {
mkdir(APP . DS . WEBROOT_DIR . DS . 'siteImg/');
chmod(APP . DS . WEBROOT_DIR . DS . 'siteImg/', 0777);
}
$imageName = $this->data['GlobalAdminSetting']['site_logo'];
unset($this->request->data['GlobalAdminSetting']['site_logo']);
if (!in_array($imageName['type'], $allowedType)) {
$this->request->data['GlobalAdminSetting']['site_logo'] = 'invalidFormat';
$this->Session->setFlash(__('Sorry, Logo could not be uploaded. only jpeg,png are allowed.'));
} else {
if ($imageName != '') {
$filePath = APP . DS . WEBROOT_DIR . DS . 'siteImg/' . $imageName['name'];
move_uploaded_file($imageName['tmp_name'], $filePath);
chmod(APP . DS . WEBROOT_DIR . DS . 'siteImg/'. $imageName['name'], 0777);
$this->GlobalAdminSetting->save(array('id' => 1, 'site_logo' => 'siteImg/'. $imageName['name']));
$this->Session->setFlash(__('site logo is uploaded Successfully.'));
} else {
$this->Session->setFlash(__('Image Not Found to upload.'));
}
}
}else{
$this->Session->setFlash(__('Image Not Found to upload.'));
}
$this->redirect(array('controller' => 'global_admin_settings', 'action' => 'logo'));
} else{
$this->set('logo',$this->GlobalAdminSetting->findById(1));
}
}