File Upload in Rest API yii2
<p>my controller file inside api/v1/controller/</p>
<pre><code>class ProfileController extends ActiveController
  {
    public $modelClass = 'app\models\Profile';

    public function behaviors()
    {
        return [
            [
                'class' =&gt; 'yii\filters\ContentNegotiator',
                'only' =&gt; 
                         ['index', 'view', 'createnew','update','search'],
                'formats' =&gt; 
                         ['application/json' =&gt; Response::FORMAT_JSON,],

            ],
            'verbs' =&gt; [
                'class' =&gt; VerbFilter::className(),
                'actions' =&gt; [
                    'index' =&gt; ['get'],            
                    'view' =&gt; ['get'],            
                    'createnew' =&gt; ['post'],       
                    'update' =&gt; ['put'],         
                    'delete' =&gt; ['delete'],        
                    'deleteall' =&gt; ['post'],
                    'search' =&gt; ['get']
                ],

            ]
        ];
    }

    public function actionCreatenew() {
        $model = new Profile();
        $model-&gt;load(Yii::$app-&gt;request-&gt;post());



        $model-&gt;asset = UploadedFile::getInstance($model, 'asset');
     
        $name = $model-&gt;user_id;

        if($model-&gt;asset) {
            
          $model-&gt;asset-&gt;saveAs('uploads/'.$name.'.
                           '.$model-&gt;asset-&gt;extension);
            $model-&gt;asset = $model-&gt;asset-&gt;name.'.'.
                            $model-&gt;asset-&gt;extension;
           
        }



        if($model-&gt;save()) {
            echo json_encode(array('status'=&gt;&quot;Success&quot;,
                     'data'=&gt;$model-&gt;attributes),JSON_PRETTY_PRINT);
        } else {
            echo json_encode(array('status'=&gt;&quot;Failure&quot;,
                     'error_code'=&gt;400,
                     'errors'=&gt;$model-&gt;errors),JSON_PRETTY_PRINT);
        }
    }

}
</code></pre>
<p>When I try to use access this from Postman like:
POST http://localhost/myapp/api/v1/profiles</p>
<p>I get Invalid Parameter – <code>yii\base\InvalidParamException</code></p>
<p>Response content must not be an array.</p>
<p>What is the issue?? help would be grateful!! Thanks</p>