--- upload_element.pages.inc.old	2008-11-17 19:41:07.000000000 +0700
+++ upload_element.pages.inc	2008-11-19 23:09:12.284465321 +0700
@@ -17,7 +17,7 @@
   // Load the element and pull out the defaults.
   $form_state = array('submitted' => FALSE);
   $form = form_get_cache($form_build_id, $form_state);
-  
+  if(!$form) $form=array();
   $form += array('#post' => array(), '#programmed' => TRUE);
   // calling form_builder would trigger the session to be cleared
   $element = locate_upload_element($form, $name);
@@ -142,6 +142,7 @@
   foreach (element_children($form) as $field_name) {
     // The comment module may trigger a false positive
     // so we need to check the type.
+    if(!$form[$name]) return;
     if ($field_name == $name && ($form[$name]['#type'] == 'upload_element' || $form[$name]['#type'] == 'image_upload_element')) {
       $form[$field_name] += $extras;
       return $form[$field_name];
