title: How to upload several files using Yii2
body: <p>Following code just uploads <strong>one</strong> file instead <strong>several</strong> files.
  Any ideas, how to fix that?
  Here is my model:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  
  //Code programmed by Thomas Kipp
  //Change it, learn it, do as u please!
  ///path:/models/
  
  namespace frontend\models;
  
  use Yii;
  use yii\base\Model;
  
  class myScriptForm extends Model{ // A new Class programmed by Thomas Kipp 
  
  ...
      public $avatar;
  ...
  
      public function rules() {
          $avatar=array();
          return [
              ['avatar[]','file']]
      }
  
  }
  
  //End of class
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my method of SiteController:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    public function actionScript() { //A new method, programmed by Thomas Kipp
          $model = new myScriptForm();
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;validate()) {
  
              $model-&gt;avatar = UploadedFile::getInstances($model, 'avatar[]');
              if ($model-&gt;avatar) {
                  echo "&lt;font size='4'&gt;&lt;br&gt;&lt;center&gt;File &lt;font color='red'&gt; "
                  . "$model-&gt;avatar&lt;font color='black'&gt; successfully uploaded."
                  . "&lt;br&gt;It's available in folder 'uploadedfiles' &lt;/font&gt;&lt;/font color&gt;&lt;/center&gt;";
                  $model-&gt;avatar-&gt;saveAs(Yii::getAlias('@uploadedfilesdir/' . $model-&gt;avatar-&gt;baseName . '.' . $model-&gt;avatar-&gt;extension));
              } else
                  echo"&lt;font size='4'&gt;&lt;br&gt;&lt;center&gt;No Upload-file selected.&lt;br&gt;"
                  . "Nothing moved into folder 'uploadedfiles' &lt;/font&gt;&lt;/center&gt;";
              return $this-&gt;render('myScript', ['model' =&gt; $model]);
          }
          else {
              return $this-&gt;render('myScript_Formular', ['model' =&gt; $model]);
          }
      }</code></pre>
  </div>
  </div>
  
  and still my Formular, which is not uploading several files:</p>
  
  <pre><code>&lt;?=
  $form-&gt;field($model,'avatar[]')-&gt;widget(FileInput::classname(), ['options' =&gt; ['accept' =&gt; 'image/*', 'multiple' =&gt; true],])
  ?&gt;
  </code></pre>