I want to configure Global Params
in Yii2.
For example this:
- This will store the server path for all your file uploads.
Yii::$app->params['uploadPath'] = Yii::$app->basePath . '/uploads/';
- This will store the Url pointing to server location for your file uploads.
Yii::$app->params['uploadUrl'] = Yii::$app->urlManager->baseUrl . '/uploads/';
When I set params like this:
'uploadPath' => Yii::$app->basePath . '/uploads/',
'uploadUrl' => Yii::$app->urlManager->baseUrl . '/uploads/',
I am getting this error:
Notice: Trying to get property of non-object
I did this for uploadPath and its working:
'uploadPath' => Yii::getAlias('@common') . '/uploads/',
But I can't get the uploadUrl and print the image. Please help, how will I set global uploadUrl in params.