? sites/default/files ? sites/default/settings.php Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.297 diff -u -p -r1.297 form.inc --- includes/form.inc 15 Oct 2008 14:17:26 -0000 1.297 +++ includes/form.inc 26 Oct 2008 15:26:29 -0000 @@ -852,7 +852,7 @@ function form_error(&$element, $message * $_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; @@ -943,9 +943,23 @@ function form_builder($form_id, $form, & if (!empty($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.632 diff -u -p -r1.632 system.module --- modules/system/system.module 14 Oct 2008 20:44:57 -0000 1.632 +++ modules/system/system.module 26 Oct 2008 15:23:57 -0000 @@ -309,6 +309,7 @@ function system_elements() { $type['file'] = array( '#input' => TRUE, '#size' => 60, + '#enctype' => 'multipart/form-data', );