Specify extensions for uploaded managed_file 's

Public

Handy way to allow files with particular extensions to be uploaded, disregarding of system settings.

Get raw version
php
  1. $form['fid'] = array(
  2. '#title' => t('Excel file to upload'),
  3. '#type' => 'managed_file',
  4. '#description' => t('Planned spendings in Excel format.'),
  5. '#upload_location' => 'public://budgets/',
  6. '#upload_validators' => array('file_validate_extensions' => array('xls xlsx')),
  7. );