Here I have a presentation with the button to delete the attached image
<?= $form->field($model, 'imageFile')->fileInput() ?> <?php if ($model->image) { echo "<div class='form-group'><div class='fimg-box'>"; echo '<img width="100" src="'.Yii::$app->params['domainFrontend'].'/images/'.$model->image.'" />'; echo Html::a('<span class="glyphicon glyphicon-trash"></span>', ['course/deleteimage', 'id' => $model->id], ['class' => 'link-del']); echo "</div></div>"; } ?> And the action itself:
public function actionDeleteimage($id) { $model = $this->findModel($id); $imgName = $model->image; unlink(Yii::getAlias('@upload/images/').$imgName); $model->image = null; $model->update(); return $this->redirect(['update', 'id' => $model->id]); } How to make this removal through Ajax or through the weep?