title: Yii 2 : Trying to get property of non-object in Yii2
body: <p><strong>Controller</strong></p>
  
  <pre><code>public function actionCreate()
      {
         $model = new RoomTypes();
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post())) {
              // get the uploaded file instance. for multiple file uploads
              // the following data will return an array
              $image = UploadedFile::getInstance($model, 'image');
  
              // store the source file name
              $model-&gt;room_type = $image-&gt;name;
              $imageName_1 = $model-&gt;room_type;
              $ext = end((explode(".", $image-&gt;name)));
  
              // generate a unique file name
              $model-&gt;pic_1 = Yii::$app-&gt;security-&gt;generateRandomString().".{$ext}";
  
              // the path to save file, you can set an uploadPath
              // in Yii::$app-&gt;params (as used in example below)
              $path = Yii::$app-&gt;params['uploadPath'] . $model-&gt;pic_1;
  
              if($model-&gt;save()){
                  $image-&gt;saveAs($path);
                  return $this-&gt;redirect(['view', 'id'=&gt;$model-&gt;_id]);
              } else {
                  // error in saving model
              }
          }
          return $this-&gt;render('create', [
              'model'=&gt;$model,
          ]);
      }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public $image;
  
  [['image'], 'safe'],
  [['image'], 'file', 'skipOnEmpty' =&gt; false, 'extensions' =&gt; 'png, jpg', 'maxFiles' =&gt; 4],
  </code></pre>
  
  <p><strong>View</strong> </p>
  
  <pre><code>    &lt;?= $form-&gt;field($model, 'room_type')-&gt;label(false)-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
  
  
      &lt;?php echo $form-&gt;field($model, 'image[]')-&gt;widget(FileInput::classname(), [
                                                'options'=&gt;['accept'=&gt;'image/*', 'multiple'=&gt;true],
                                                'pluginOptions'=&gt;['allowedFileExtensions'=&gt;['jpg','gif','png']
  'slugCallback' =&gt; new JsExpression(function(room_type) 
  {return room_type;},),]]); 
                                          ?&gt;
  </code></pre>
  
  <p>Getting this error while uploading the file. <strong>Also it's not accepting multiple image  for upload,</strong> what's wrong with it?
  How to achieve this multiple file upload???</p>