คุณขาดสิ่งนี้ไปในนิยามของแบบฟอร์ม
   $form['#attributes']['enctype'] = 'multipart/form-data'; // If this is not here, upload will fail on submit
นี่คือตรรกะที่ฉันใช้ในการสร้างวิดเจ็ตอัพโหลดไฟล์ในแบบฟอร์ม:
   // these give us the file upload widget: 
   $form['#attributes']['enctype'] = 'multipart/form-data'; // If this is not here, upload will fail on submit
   $form['fid'] = array( '#title'        => t('Upload image'),
                         '#type'         => 'file',
                         '#description'  => t('Images must be one of jpg, bmp, gif or png formats.'),
                       ); 
และนี่คือคู่ของตรรกะนั้นซึ่งฉันมีในการโทรกลับตรวจสอบความถูกต้องของแบบฟอร์มของฉันเพราะฉันมีข้อ จำกัด ชื่อไฟล์ภาพในตรรกะของฉัน แต่คุณสามารถวางสิ่งนี้ในการเรียกกลับส่งถ้าคุณต้องการ:
   // @see: http://api.drupal.org/api/function/file_save_upload/6
   // $file will become 0 if the upload doesn't exist, or an object describing the uploaded file
   $file = file_save_upload( 'fid' );
   error_log( 'file is "'.print_r( $file, true ).'"' );
   if (!$file) {
      form_set_error('fid', t('Unable to access file or file is missing.'));
   }
แค่นั้นแหละ. 
               
              
$form['#attributes']['enctype']Drupal 7 ดูแลโดยอัตโนมัติ