### Eclipse Workspace Patch 1.0 #P drupal-6-dev Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.265.2.10 diff -u -r1.265.2.10 form.inc --- includes/form.inc 13 Aug 2008 23:59:12 -0000 1.265.2.10 +++ includes/form.inc 27 Aug 2008 08:38:29 -0000 @@ -846,7 +846,7 @@ * $_POST data. */ function form_builder($form_id, $form, &$form_state) { - static $complete_form, $cache; + static $complete_form, $cache, $enctype; // Initialize as unprocessed. $form['#processed'] = FALSE; @@ -937,9 +937,24 @@ if (isset($form['#cache'])) { $cache = $form['#cache']; } - // We are on the top form, we can copy back #cache if it's set. - if (isset($form['#type']) && $form['#type'] == 'form' && isset($cache)) { - $form['#cache'] = TRUE; + + // If an element requires to set the forms content type enctype + // attribute, we need to store this info in a static $enctype + // flag to update the parent form element. + // E.g. For files, non-ASCII data, and binary data. + if (isset($form['#enctype'])) { + $enctype = $form['#enctype']; + } + // We are on the top form, we can copy back #cache if it's set, + // and set the required enctype as required. + if (isset($form['#type']) && $form['#type'] == 'form') { + if (isset($cache)) { + $form['#cache'] = TRUE; + } + // If there is a file element, we set the form encoding. + if (isset($enctype)) { + $form['#attributes']['enctype'] = $enctype; + } } return $form; } Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.585.2.17 diff -u -r1.585.2.17 system.module --- modules/system/system.module 14 Aug 2008 00:13:30 -0000 1.585.2.17 +++ modules/system/system.module 27 Aug 2008 08:38:31 -0000 @@ -180,7 +180,7 @@ $type['select'] = array('#input' => TRUE, '#size' => 0, '#multiple' => FALSE, '#process' => array('form_expand_ahah')); $type['weight'] = array('#input' => TRUE, '#delta' => 10, '#default_value' => 0, '#process' => array('process_weight', 'form_expand_ahah')); $type['date'] = array('#input' => TRUE, '#process' => array('expand_date'), '#element_validate' => array('date_validate')); - $type['file'] = array('#input' => TRUE, '#size' => 60); + $type['file'] = array('#input' => TRUE, '#size' => 60, '#enctype' => 'multipart/form-data',); // Form structure $type['item'] = array('#value' => '');