title: How to resize image yii2 when uploading
body: <p>This is my post controller function. I always upload images less then <code>200x200</code>, and those images are stored in the <em>'upload'</em> folder. After uploading the image, the id number is changed to something like <code>4546464.png</code>. But I want to change the image size to <code>60x60</code> when uploading and store it after changing the size and quality to <code>60x60x30</code>. This code uploads fine but not changing size and quality.</p>
  
  <pre><code>public function actionCreate() {
      $model = new Monitor();
  
      if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
          if ($model-&gt;payment_processor) {
              $model-&gt;payment_processor = implode(',', $model&gt;payment_processor);
          }
  
          $model-&gt;file = UploadedFile::getInstance($model, 'file');
  
          if ($model-&gt;file != '') {
              $model-&gt;image = time() . '.' . $model-&gt;file-&gt;extension;
          }
  
          $model-&gt;update_at = date('Y-m-d h:i:s');
          $model-&gt;save();
  
          if ($model-&gt;file != '') {             
              $model-&gt;file-&gt;saveAs('upload/' . $model-&gt;image);               
          }
          return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
      } else {
          return $this-&gt;render('create', ['model' =&gt; $model]);
      }
  }
  </code></pre>