表单已提交但 getInstance() returns 错误

Form submitted but getInstance() returns false

我在我的应用程序中使用 2amigos file upload widget。 \ 我的视图文件如下所示:

<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>

在我的控制器操作中,我写道:

if (UploadedFile::getInstance($model, 'file')) {
    echo "yes";
    // do my staff...
    exit;
} else {
    echo "no";
    // confused. why no ?
    exit;
}

我很困惑,为什么图片没有上传;为什么 getInstance() returns 为假?

我做错了什么?

p.s 我在发布 $this 之前阅读了 。 p.s.s 其他字段值正确发布并按预期工作。

利用你已经通过了

['enctype' => 'multipart/form-data']

作为 $form = ActiveForm::begin();

中的选项

http://www.yiiframework.com/doc-2.0/guide-helper-html.html#creating-forms