我上传的图片验证无效..
add.ctp
<?php echo $this->Form->create('User',array('enctype'=>'multipart/form-data', 'novalidate'=>'true')); ?>
<?php echo $this->Form->file('users_image', array('type' => 'file', 'class' => 'm-wrap large','id'=>'ProfileImage')); ?>
<?php echo $this->Form->end(__('Submit')); ?>
user.php的
public $validate = array(
'uesrs_image' => array(
'rule' => array(
'extension',
array('jpeg', 'jpg')
),
'message' => 'Please supply a valid image.'
)
);
当我上传.png图片时,它已成功上传
答案 0 :(得分:0)
试试这个
public $validate = array(
'uesrs_image' => array(
'extension' => array(
'rule' => array('extension', array('jpeg', 'jpg')),
'message' => 'Only jpeg, jpg files',
),
'upload-file' => array(
'rule' => array('uploadFile'), // Is a function below
'message' => 'Error uploading file'
)
)
);