Access allowed file types (for upload)

Hi to @all !

How i can access from within a controller the allowed file types I setted in rules like this :




<?php

public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

                        array('name','file','allowEmpty'=>false,'types'=>'jpg,jpeg,bmp,png,gif,zip','wrongType'=>'Wrong file type !'

...........

?>



I found how i can reuse the same array @ all places:

in config/main.php (i added a new param):




    'params'=>array(

        'allowedTypes'=>array('jpg','jpeg','png','gif'),

        'adminEmail'=>'admin@localhost',



Then @model:




    public function rules() {

        return array(

        array('title','file','allowEmpty'=>false,'types'=>Yii::app()->params['allowedTypes'],...

        ...



I would put this array in the model thus model related things should be stored directly in it.




<?php

public $allowed_types = array('jpg','jpeg','bmp','png','gif');


public function rules()

{

   return array(

      array('name','file','allowEmpty'=>false,'types'=>$this->allowed_types,'wrongType'=>'Wrong file type !'

   );

}

?>



Oh, i know but i prefer using config/main.php

it’s a more generic and newbie accessible file