diff --git a/includes/form.inc b/includes/form.inc
index 6da6440ba809ea3e382a3e35896744b6706b5a31..512f4d731eeb4ea66e06cc09fd2bc98d850c3510 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -945,7 +945,7 @@ function form_builder($form_id, $form, &$form_state) {
   }
   // If there is a file element, we need to flip a static flag so later the
   // form encoding can be set.
-  if ($form['#type'] == 'file') {
+  if (isset($form['#type']) && $form['#type'] == 'file') {
     $file = TRUE;
   }
   if (isset($form['#type']) && $form['#type'] == 'form') {