function theme_file

7.x theme_file($variables)

Returns HTML for a file upload form element.

For assistance with handling the uploaded file correctly, see the API provided by


$variables: An associative array containing:

  • element: An associative array containing the properties of the element. Properties used: #title, #name, #size, #description, #required, #attributes.

Related topics

4 theme calls to theme_file()
FileFieldDisplayTestCase::testNodeDisplay in drupal/modules/file/tests/file.test
Tests normal formatter display on node display.
file_managed_file_process in drupal/modules/file/file.module
Process function to expand the managed_file element type.
theme_file_formatter_table in drupal/modules/file/
Returns HTML for a file attachments table.
theme_file_link in drupal/modules/file/file.module
Returns HTML for a link to a file.


drupal/includes/, line 3956
Functions for form and batch generation and processing.


function theme_file($variables) {
  $element = $variables['element'];
  $element['#attributes']['type'] = 'file';
  element_set_attributes($element, array('id', 'name', 'size'));
  _form_set_class($element, array('form-file'));

  return '<input' . drupal_attributes($element['#attributes']) . ' />';