L
L
Light7772015-11-04 18:48:40
Yii
Light777, 2015-11-04 18:48:40

How to delete a file physically in Yii2?

Hello! Tell me how to delete a file in Yii2 physically?
Generated a regular KRUD with image loading. The path to the images is stored in the database, and the image itself is stored in the folder. When deleting, only the record in the database is deleted, and the file remains.
Please tell me how to delete the file ...
Delete function

public function actionDelete($id)
    {
        $this->findModel($id)->delete();
        return $this->redirect(['index']);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Askar Fuzaylov, 2015-11-04
@Light777

unlink('/path/to/file');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question