Hi there!
This may be a bit embarassing, but how can I best make a property value available to all my actions in a specific controller?
Let’s assume I have following controller:
class UploadController extends Controller
{
public function actionIndex() {
if ($handle = opendir($FOLDER)) {
// [...]
}
$this->render('index');
}
public function actionSend() {
$myfile = $FOLDER . DIRECTORY_SEPARATOR . $file;
// [...]
}
}
And $FOLDER should be something like
$FOLDER = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "media" . DIRECTORY_SEPARATOR . "uploads"
Where should I put $FOLDER = […] so I can access it from actionIndex() and actionSend()?
Normally I would declare $_folder as a protected property and assign the value in the __constructor, but when I use a __constructor, Yii can’t find my index template any more. I guess because the __constructor of the base CController gets overwritten.
Regards
ycast