According to the api docs, #default_value is a supported property of the file form control.

However this isn't working in my testing. Example:

  $form[$fieldname] = array(
    '#type' => 'file',
    '#title' => t($field->label),
    '#description' => ($node->$fieldname ? t('"%filename" has been uploaded. If you upload another file, the current file will be replaced.', array('%filename' => $node->$fieldname->filename)) : '') . t($field->description),
    '#required' => $field->required,
    '#weight' => $field->weight,
    '#default_value' => 'TESTING.txt',
    );

Comments

dgtlmoon’s picture

I agree, its not working here either

dgtlmoon’s picture

turns out it is not supported on most browsers due to security issues

(ie: you could set the default value to be c:\somesecretfile, hide the file field in a no-display div and then just show the submit button...)

webchick’s picture

Version: 4.6.6 » 4.7.2
Status: Active » Closed (won't fix)

Yeah. See Input File Value thread on Evolt.org for further details.

The value type in file input fields is not supported by any browser that I know of for these reasons. Doesn't make sense for Drupal to support it either. Setting to won't fix.