Skip to content

Kirby 4.1.0

File::create()

Creates a new file on disk and returns the File object. The store is used to handle file writing, so it can be replaced by any other way of generating files.

File::create(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

Exceptions

Parent class

Kirby\Cms\File

$props parameter

Name Type Description
source * string source thingy

Example

$file = File::create([
  'source'     => kirby()->root('assets').'/images/some-image.jpg',
  'parent'     => page('photography')->children()->listed()->first(),
  'filename'   => 'new-image.jpg',
  'template' => 'cover',
  'content'   => [
    'caption'   => 'A nice view from above',
  ]
]);