Skip to content

Kirby 3.7.5

$file->delete()

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

$file->delete(): bool

Return type

bool

Parent class

Kirby\Cms\File

Example

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();
    }
}