You are here

function _webform_attachments_component in Webform 7.3

Same name and namespace in other branches
  1. 6.3 webform.api.php \_webform_attachments_component()
  2. 7.4 webform.api.php \_webform_attachments_component()

Return an array of files associated with the component.

The output of this function will be used to attach files to e-mail messages.

Parameters

$component: A Webform component array.

$value: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema.

Return value

An array of files, each file is an array with following keys:

  • filepath: The relative path to the file.
  • filename: The name of the file including the extension.
  • filemime: The mimetype of the file.

This will result in an array looking something like this:


  array[0] => array(
    'filepath' => '/sites/default/files/attachment.txt',
    'filename' => 'attachment.txt',
    'filemime' => 'text/plain',
  );
  

Related topics

File

./webform.api.php, line 599
Sample hooks demonstrating usage in Webform.

Code

function _webform_attachments_component($component, $value) {
  $files = array();
  $files[] = (array) file_load($value[0]);
  return $files;
}