I have to develop a profile page which has user image shown and an update button to change the profile picture. To show image and update button in view looks like below
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= Html::img($imgPath,['width'=>100,'height'=>100]);?>
<?= $form->field($model, 'imageFile')->fileInput(); ?>
<?= Html::submitButton('Update Profile Picture',['class'=>'btn btn-primary','id'=>'uploadButton']) ?>
<?php ActiveForm::end() ?>
With fileInput I am choosing new file and saving it on server with below line
$model->imageFile->saveAs('uploads/profilepictures/' . $session['user_name'] . '_profimg.' . $model->imageFile->extension);
The image is successfully getting uploaded to server (overwriting the old image) but when I refresh my web page the old image is displayed even though it is replaced in server with new one. Html::img is still fetching the older image not sure why (and from where??). Someone please help!