Skip to content

Kirby 5.0.4

$page->createFile()

Creates a new file

$page->createFile(array $props, bool $move = false): Kirby\Cms\File

Parameters

Name Type Default Description
$propsrequired array no default value
$move bool false If set to true, the source will be deleted

Return type

Kirby\Cms\File

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

Parent class

Kirby\Cms\Page

Examples

Create new file from a local file path

$file = $page->createFile([
    'filename' => 'tree.jpg',
    'template' => 'image',
    'source'   => $kirby->root('assets'). '/images/' . 'tree.jpg',
    'parent'   => $page,
    'content'  => [
        'alt' => 'Single tree on a field'
    ],
]);