jackhad
(Jackhad)
June 10, 2016, 7:20am
1
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
selvakumar
(Selvakumar Kaliyappan)
September 29, 2016, 11:30am
4
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">
<input type="file" id="model_asset" name="Model[asset]" ng-model="Model.asset" required/>
<button type="submit" class="btn" title="Submit">Submit</button>
</form>[/html]
If not please add it and check?
jackhad
(Jackhad)
September 29, 2016, 11:35am
5
Selvakumar:
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">
<input type="file" id="model_asset" name="Model[asset]" ng-model="Model.asset" required/>
<button type="submit" class="btn" title="Submit">Submit</button>
</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
selvakumar
(Selvakumar Kaliyappan)
October 4, 2016, 2:00pm
6
You should use
\yii\web\UploadedFile::getInstanceByName('asset'); instead of getInstance().
checkout this Link