Skip to content

Kirby 5.0.4

$file->delete()

Deletes the file. The store is used to manipulate the filesystem or whatever you prefer.

$file->delete(): bool

Return type

bool

This method modifies the existing $file object it is applied to and returns it again.

Parent class

Kirby\Cms\File

Examples

if ($file = $page->file('old-file.pdf')) {
    try {
        $file->delete();
        echo 'The file has been deleted';

    } catch(Exception $e) {
        echo 'The file could not be deleted';
        // optional reason: echo $e->getMessage();
    }
}