Search code examples
filedrupaldrupal-7field

Drupal 7.31 custom file field and it's extensions


I have problem with my custom created field for custom node type. This is field instance configuration:

'attachments' => array(
    'field_name'     => 'vintranet_talk_attachments',
    'label'          => t('Attachments'),
    'entity_type'    => 'node',
    'bundle'         => 'mynodetypename',
    'widget'         => array(
        'type' => 'file_mfw',
    ),
    'settings'       => array(
        'max_filesize'       => 1024 * 1024 * 10,
        'file_directory'     => 'my/path',
        'file_extensions'    => 'jpg,png,gif,pdf,zip,doc,rtf,xdoc,rar,txt',
        'description_field'  => 1,
    ),
    'display'        => array(
        'default' => array(
            'type' => 'file_table',
        ),
    ),
),

After installing my module, I wanted to add new node and add some attachments, but I get this error:

enter image description here

Why I can't upload my *.txt file (same with jpg and others) even if I have this file format in "Allowed file types" list?

Only after editing particular node type field settings from the backend page (just by pressing "save" button) everything works perfect...


Solution

  • The answer is to change value of file_extensions to jpg png gif pdf zip doc rtf xdoc rar txt.