Код: Выделить всё
<?php public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
'deleteimage' => ['POST'],
],
],
];
}
public function actionDeleteimage($id) {
$model = $this->findModel($id);
$orig = $model->getUploadPath('image_name');
if (is_file($orig)) {
if(unlink($orig)){
$model->image_name = null;
}
}
return $this->render('update', [
'model' => $model,
]);
} ?>
//_form.php
<?= Html::a('Удалить картинку', ['deleteimage', 'id' => $model->id], [
'class' => 'btn btn-danger',
'role' => 'button',
'data' => [
'confirm' => 'Уверены, что хотите удалить картинку?',
'method' => 'post',
],]) ?>
Код: Выделить всё
article/default/deleteimage?id=880
Код: Выделить всё
article/default/update?id=877