I'm using 2amigos file upload widget in my app. \\ My view file looks like:
<fieldset class="form-control-sm">
<div class="form-group">
<label for="patient-file" class="file col-md-4 control-label">Profil şəkili</label>
<div class="col-md-8">
<?= $form->field($model, 'file')->widget(\dosamigos\fileinput\BootstrapFileInput::className(), [
'options' => [
// 'name' => 'file',
'accept' => 'image/*',
'multiple' => false,
],
'clientOptions' => [
'previewFileType' => 'image',
'showUpload' => false,
'browseClass' => 'btn btn-primary-outline',
'removeClass' => 'btn btn-danger-outline',
'removeIcon' => '<i class="glyphicon glyphicon-trash"></i> '
]
])->label(false); ?>
</div>
</div>
</fieldset>
In my controller action I wrote:
if (UploadedFile::getInstance($model, 'file')) {
echo "yes";
// do my staff...
exit;
} else {
echo "no";
// confused. why no ?
exit;
}
I'm confused that, why image's not uploading; why getInstance() returns false?
What's I'm doing wrong?
ps I read that post before posting $this. pss Other field values posting correctly and working as expected.
Make use you have passed
['enctype' => 'multipart/form-data']
as options in your $form = ActiveForm::begin();
http://www.yiiframework.com/doc-2.0/guide-helper-html.html#creating-forms
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.