activeFileField() 如何实现只能图片上传?
activeFileField() 如何实现只能图片上传?
model 里的规则
public $image; //别忘了声明
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
....
array('image', 'file','allowEmpty'=>true ,
'types'=>'jpg, gif, png',
'maxSize'=>1024 * 1024 * 10, // 10MB
'tooLarge'=>'The file was larger than 10MB. Please upload a smaller file.',
),
);
}
Thanks, bluefinger