Custom module 'managed_file' variable info keeps disappearing
Scott's code is right (and is nearly identical to what I had) but the final step I was missing is in the form's submit handler, where I needed to grab the file that was uploaded and mark it as permanent, and add a file usage to tell Drupal the file was in use. By default Drupal treats uploaded files as temporary and they are deleted from the database and filesystem after 6 hours (when cron runs).

Here's the submit handler code.

function MODULE_admin_settings_submit($form, &amp;$form_state) {
  global $user;
  if (isset($form_state['values']['custom_managed_jpg']) &amp;&amp; $form_state['values']['custom_managed_jpg']!="") {
    // Load the file via file.fid.
    $file = file_load($form_state['values']['custom_managed_jpg']);
    // Change status to permanent.
    $file-&gt;status = FILE_STATUS_PERMANENT;
    file_save($file);
    // Record that the module (in this example, "custom module") is using the file. 
    file_usage_add($file, 'custom_module', 'custom_managed_jpg', $user-&gt;uid); 
  } 
}