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