There is no way in Cakephp to validate fileinput field.
You can do it by custom validation rules like below example
for view file
<?php
echo $this->Form->file('image');
echo $this->Form->error('image');
?>
For model file
<?php
public $validate = array(
'image' => array(
'rule' => array('chkImageExtension'),
'message' => 'Please Upload Valid Image.'
)
);
public function chkImageExtension($data) {
$return = true;
if($data['image']['name'] != ''){
$fileData = pathinfo($data['image']['name']);
$ext = $fileData['extension'];
$allowExtension = array('gif', 'jpeg', 'png', 'jpg');
if(in_array($ext, $allowExtension)) {
$return = true;
} else {
$return = false;
}
} else {
$return = false;
}
return $return;
}
?>