### Eclipse Workspace Patch 1.0
#P Drupal-7-Dev
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.613
diff -u -r1.613 system.module
--- modules/system/system.module	21 Aug 2008 19:36:38 -0000	1.613
+++ modules/system/system.module	27 Aug 2008 08:23:03 -0000
@@ -288,6 +288,7 @@
   $type['file'] = array(
     '#input' => TRUE,
     '#size' => 60,
+    '#enctype' => 'multipart/form-data',
   );
 
 
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.281
diff -u -r1.281 form.inc
--- includes/form.inc	17 Aug 2008 11:08:23 -0000	1.281
+++ includes/form.inc	27 Aug 2008 08:22:52 -0000
@@ -841,7 +841,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;
@@ -932,9 +932,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;
 }
