getInstance not working File Update in REST API yii2

Hi Im using REST API in yii 2 \yii\web\UploadedFile::getInstance is not getting file in my function.for debugging purpose I tried with $_FILES[‘asset’] its printing with values.but not getting file instance using \yii\web\UploadedFile::getInstance


$updateFile = $_FILES['asset']; //Printing values

$model->asset = \yii\web\UploadedFile::getInstance($model, 'asset'); //Not printing,its empty



What is the issues,I couldn’t validate If i process the file with $_FILES.Any help would be grateful!! Thanks in Advance

Did find the answer?

Not Yet

Is your form in the following manner? And the input field has a name attribute?

[html]<form id="model-form" name="model-form" method="post" role="form" ng-submit="submitForm()" role="form" enctype="multipart/form-data">

&lt;input type=&quot;file&quot; id=&quot;model_asset&quot; name=&quot;Model[asset]&quot; ng-model=&quot;Model.asset&quot; required/&gt;


&lt;button type=&quot;submit&quot; class=&quot;btn&quot; title=&quot;Submit&quot;&gt;Submit&lt;/button&gt;

</form>[/html]

If not please add it and check?

Im not using Angular JS.My question is about to get the file content from REST API

You should use


\yii\web\UploadedFile::getInstanceByName('asset'); instead of getInstance().

checkout this Link