Field::addValue($file[,$method])

Version 3.8

Add new file

Filename and title are taken from the name of the file, if omitted.

Return value

Bool

Arguments

$file
string: Filename
string: File id
array: Values for new file :TiedostoKentta: Copy files in field

$method :string: addvalue Create file and add id to field values. :string: create Create file and return file array.

Full documentation

Add file by filename:

$Project->contract->addValue($fileName);

Add file by file id: (version 2025.1)

$Project->contract->addValue($fileId);

Additional information as array:

$Project->contract->addValue(Array(
  'title'       => 'Project Contract',
  'description' => 'Detailed information about the project.',
  'filename'    => 'ProjectContract.doc',
  'file'        => $fileName
));

Add file with given content:

$Project->contract->addValue(Array(
  'title'       => 'Project Contract',
  'description' => 'Detailed information about the project.',
  'filename'    => 'Contract.txt',
  'content'     => 'This is the file content.'
));

Add files from another page/field: (version 2025.1)

$Project->contract->addValue($OtherProject->contract);