how to call a constant value throughout controller


In root index.php:




In controller I am calling this constant while uploading image under create function, like


while uploading I am getting error as " Use of undefined constant UPLOAD_DIRECT - assumed ‘UPLOAD_DIRECT’ ".

I am new to yii framework can anyone help me to sort out this.

Thanks waahi. :blink:

Hi Sally,

You can try to create a Helper class and declare a constant:

class Helper {

const UPLOAD_DIRECT = Yii::app()->baseUrl.'/images/upload_folder';


In your controller:


Thanku for ur reply,

where do I create helper class?

You can create it inside model folder.