Populate a file field on edit form
I ended up using this

if ($form_state['storage']['file'] != '0') {
  $file = file_save_upload('file', array(
    'file_validate_extensions' =&gt; array('png gif jpg jpeg'),
    'file_validate_is_image' =&gt; array(),
  ));

  // If the file passed validation:
  if (isset($file-&gt;filename)) {
    // Move the file, into the Drupal file system
    if (file_move($file, $file-&gt;filename)) {
      // Update the new file location in the database.
      drupal_write_record('files', $file, 'fid');
      // Save the file for use in the submit handler.
      $form_state['storage']['file'] = $file;
    }
    else {
      form_set_error('file', t('Failed to write the uploaded file the site\'s file folder.'));
    }
  }

  $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_set_status($file, FILE_STATUS_PERMANENT);
}

$fid = $file-&gt;fid;
$icon = $file-&gt;filename;

if (!isset($fid)) { 
  $fid = $form['fid']['#value']; 
}

if (!isset($icon)) { 
  $icon = $form['icon']['#value']; 
}

$id = $form['id']['#value'];
$url = $form['url']['#value'];
$title = $form['title']['#value'];