我想在yii2中使用fileinput kartik更新图像。创建时成功,但更新时不成功。这是我的view.php
<?= $form->field($bukuForm, 'gambar_buku', ['labelOptions' => ['class' => 'col-sm-2 col-md-2 col-lg-2']])->label('Gambar')->widget(FileInput::classname(), [
'options' => ['multiple' => false],
'pluginOptions' => [
// 'previewFileType' => 'image',
'allowedFileExtensions' => ['png', 'jpg', 'jpeg', 'gif'],
'showUpload' => false,
'initialPreview' => [
Html::img(\Yii::$app->urlManagerBackend->baseUrl . '/web/uploads/images/bahanpustaka/' . $bukuForm->gambar_buku, ['width' => 200, 'height' => 250, 'class' => 'file-preview-image'])
],
'initialCaption' => $bukuForm->gambar_buku,
],
'id' => 'field_gambar',
])->hint('File: .png, .jpg, .jpeg, .gif'); ?>
这是我的controller.php
if ($bukuForm->load(Yii::$app->request->post())) {
$bukuForm->gambar_buku = UploadedFile::getInstance($bukuForm, 'gambar_buku');
echo $bukuForm->gambar_buku;
die();
当我运行更新功能时,gambar_buku的结果为NULL。 这是我点击更新按钮时的图像。
有什么问题?