Skip to content

Kirby 4.5.0

$site->createFile()

Creates a new file

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

Parameters

Name Type Default Description
$props * array
$move bool false If set to true, the source will be deleted

Return type

Kirby\Cms\File

Parent class

Kirby\Cms\Site

Example

<?php

$kirby->impersonate('kirby');

$newPage = $site->createFile(
    [
        'filename' => 'trees.jpg',
        'parent'   => $site,
        'source'   => $kirby->root('assets') . '/images/trees.jpg',
        'template' => 'image',
        'content' => [
            'alt' => 'A beautiful flower',
        ],
    ]
);