Reference

Guide

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): Kirby\Cms\File

Parameters

Name Type Default Description
$props array

Return type

Kirby\Cms\File

The $props parameter

Property Type Description
blueprint array Blueprint definition
content array Field values
filename string Field values
parent* Kirby\Cms\Model $site, $page or $user
root string
source* string
template string
translations array Language codes with subarrays of field values
url string

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',
  ]
]);

Source code

kirby/src/Cms/FileActions.php#L154