When programmatically adding file field, how to set allowed file extensions? I'm trying to add a custom node type in hook_install() for my custom module. I've been able to add the fields I want but can't seem to find a way to set the allowed file extensions for file fields. (it defaults to .txt)

The example below shows how I create my file field. I have tried setting both allowed_file_extensions and file_extensions in the settings array but that does not seem to work. 

How would I set the allowed file extensions for a file field?

    field_create_field(array(
        'field_name' =&gt; 'xxx_video',
        'type' =&gt; 'file',
        'settings' =&gt; array('allowed_file_extensions' =&gt; array('mp4', 'avi', 'mov', 'wmv', '3gp', 'mpeg', 'mpeg2', 'mkv')),
        'entity_type' =&gt; array('node'),
    ));
    field_create_instance(array(
      'field_name' =&gt; 'xxx_video',
      'required' =&gt; true,
      'entity_type' =&gt; 'node',
      'bundle' =&gt; 'xxx',
      'label' =&gt; t('Video'),
      'description' =&gt; t('Video to play in smartbox.'),
    ));
The allowed file extension settings are added to the field instance settings, rather than the global field settings.

The variable is called 'file_extensions' and not 'allowed_file_extensions'

It is also a textfield string value, rather than an array.

You could try something like:

field_create_field(array(
    'field_name' =&gt; 'xxx_video',
    'type' =&gt; 'file',
    'entity_type' =&gt; array('node'),
));
field_create_instance(array(
  'field_name' =&gt; 'xxx_video',
  'required' =&gt; true,
  'entity_type' =&gt; 'node',
  'bundle' =&gt; 'xxx',
  'label' =&gt; t('Video'),
  'settings' =&gt; array('file_extensions' =&gt; 'mp4, avi'),
  'description' =&gt; t('Video to play in smartbox.'),
));