#default_value not working for file field type

samc - April 24, 2006 - 04:06
Project:Drupal
Version:4.7.2
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

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:

<?php
  $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',
    );
?>

#1

dgtlmoon - May 25, 2006 - 04:57

I agree, its not working here either

#2

dgtlmoon - June 24, 2006 - 17:43

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...)

#3

webchick - June 24, 2006 - 20:59
Version:4.6.6» 4.7.2
Status:active» 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.

 
 

Drupal is a registered trademark of Dries Buytaert.