edit form: default value file field On my edit form I need to fill in the file field, this is my current code:

    $form['file'] = array( 
    '#title'        =&gt; t('Upload image'),
    '#type'         =&gt; 'file',
    '#description'  =&gt; t('Images must be one of jpg, bmp, gif or png formats.'),
    '#default_value'        =&gt; "$link-&gt;icon",
    '#ajax'         =&gt; array(
      'wrapper'       =&gt; 'box',
      'name'          =&gt; 'icon2',
    ),
);


but the file field remains empty, in this way the admin has to reselect the desired image each time he edits the entry. The field returns 'no file chosen'.

Any ideas?  

Update I

$form['file'] = array( 
    '#title'        =&gt; t('Upload image'),
    '#type'         =&gt; 'managed_file',
    '#description'  =&gt; t('Images must be one of jpg, bmp, gif or png formats.'),
    '#default_value' =&gt; variable_get('', $fid),
    '#upload_location' =&gt; 'public://',
    '#ajax'         =&gt; array(
      'wrapper'       =&gt; 'box',
      'name'          =&gt; 'icon2',
    ),
);
According to the FAPI documentation, #default_value isn't a valid property for a file element which is probably why adding it to the array has no effect.

You might have better luck using a managed file element instead; although the documentation also states that a #default_value is not valid for that type either, I've used it successfully for ages now. The default value needs to be a file id (fid) which references a file in the file_managed table.