title: Yii2 POST image to model in API without Yii2 Naming convention
body: <p>I'm creating an endpoint for a mobile application to send a image to the server. I'm posting the image with the POSTMAN extension for chrome. The image is in the <code>$_FILES</code> variable, and named <code>image</code>. How can I load this image into a model, or the <code>UploadedFile</code> class? The <code>$model-&gt;load(Yii::$app-&gt;request-&gt;post())</code> line does not correctly load the file, as it is not in Yii2's naming convention for forms.</p>
  
  <p>It's currently returning:</p>
  
  <pre><code>{
      "success": false,
      "message": "Required parameter 'image' is not set."
  }
  </code></pre>
  
  <p><strong>Code</strong></p>
  
  <p><em>models\Image.php</em></p>
  
  <pre><code>&lt;?php
  namespace api\modules\v1\models;
  
  use yii\base\Model;
  use yii\web\UploadedFile;
  
  class Image extends Model
  {
      /**
       * @var UploadedFile
       */
      public $image;
  
      public function rules()
      {
          return [
              [['image'], 'file', 'skipOnEmpty' =&gt; false, 'extensions' =&gt; 'png, jpg'],
          ];
      }
  
      public function upload()
      {
          $path = dirname(dirname(__FILE__)) . '/temp/';
          if ($this-&gt;validate()) {
              $this-&gt;image-&gt;saveAs($path . $this-&gt;image-&gt;baseName . '.' . $this-&gt;image-&gt;extension);
              return true;
          } else {
              die(var_dump($this-&gt;errors));
              return false;
          }
      }
  }
  </code></pre>
  
  <p><em>controllers\DefaultController.php</em></p>
  
  <pre><code>&lt;?php
  namespace api\modules\v1\controllers;
  
  use api\modules\v1\models\Image;
  use yii\web\Controller;
  use yii\web\UploadedFile;
  use Yii;
  
  class DefaultController extends Controller
  {
      public $enableCsrfValidation = false;
  
      public function actionIndex()
      {
          Yii::$app-&gt;response-&gt;format = \yii\web\Response::FORMAT_JSON;
  
          $model = new Image();
  
          if (Yii::$app-&gt;request-&gt;isPost) {
              if($model-&gt;load(Yii::$app-&gt;request-&gt;post()))
              {
                  $model-&gt;image = UploadedFile::getInstance($model, 'image');
                  if ($model-&gt;upload()) {
                      // file is uploaded successfully
                      return ['success' =&gt; true, 'message' =&gt; 'File saved.'];
                  }
                  else return ['success' =&gt; false, 'message' =&gt; 'Could not save file.'];
              }
              else return ['success' =&gt; false, 'message' =&gt; 'Required parameter \'image\' is not set.'];
          }
          else return ['success' =&gt; false, 'message' =&gt; 'Not a POST request.'];
      }
  }
  </code></pre>
  
  <p><strong>Postman</strong>
  <a href="https://i.stack.imgur.com/KGesX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGesX.png" alt="Postman POST request"></a></p>