Recoverable fatal error after form submission in drupal7
Here is an example of a file upload with some validation, hope it helps

function file_upload_form_validate($form, &amp;$form_state) {

  $file = file_save_upload('file', array(
    'file_validate_extensions' =&gt; array('txt csv'), 
    'file_validate_size' =&gt; array(10000000),
  ));
  // If the file passed validation:
  if ($file) {
    // Move the file, into the Drupal file system
    if ($file = file_move($file, 'public://')) {
      // Save the file for use in the submit handler.
      $form_state['storage']['file'] = $file;
    }
    else {
      form_set_error('file', 'there was an error uploading the file');
    }
  }
  else {
    form_set_error('file', 'No file uploaded');
  }
}

function file_upload_form_submit($form, &amp;$form_state) {
  $file = $form_state['storage']['file'];
  // We are done with the file, remove it from storage.
  unset($form_state['storage']['file']);
  // Make the storage of the file permanent
  $file-&gt;status = FILE_STATUS_PERMANENT;
  // Save file status.
  file_save($file);
  // here you can save your data
  $firstname = $form_state['values']['name'];
  $username = $form_state['values']['username'];
  $password = $form_state['values']['password'];
  $year_of_birth = $form_state['values']['year_of_birth'];
  $email = $form_state['values']['email'];

  db_insert('registration')-&gt;fields(array(
    'firstname' =&gt; $firstname,
    'username' =&gt; $username,
    'password' =&gt; $password,
    'yearofbirth' =&gt;$year_of_birth,
    'email' =&gt; $email,
    'file' =&gt; $file-&gt;uri,))
  -&gt;execute();

}