title: Yii2 - rename file on upload if the file with the same name exist
body: <p>How can I rename file if the file with the same name exist (prevent overwrite)? This method is used for uploading file:</p>
  
  <pre><code>// Upload user avatar
      public function upload()
      {
          if ($this-&gt;validate()):
  
              $this-&gt;avatar-&gt;saveAs('../web/images/avatars/' . $this-&gt;avatar-&gt;baseName . '.' . $this-&gt;avatar-&gt;extension);
              return true;
  
          endif;
  
          return false;
      }
  </code></pre>