title: Set FILE_STATUS_PERMANENT for Appearance Settings File Upload
body: <p>In Drupal 7, I have a theme with the following code in theme-settings.php:</p>
  
  <pre><code>function greytheme_form_system_theme_settings_alter(&amp;$form, $form_state)
  {
      $form["greytheme_home_img"] = array(
          '#type'          =&gt; 'managed_file',
          '#title'         =&gt; t('Home Page Image'),
          '#description'   =&gt; t("Home page image to be used in the ribbon."),
          // fileID (fid) used to display the file later
          '#default_value' =&gt; variable_get('greytheme_home_img', ''), 
          '#upload_location' =&gt; 'public://homeimg/',
          '#upload_validators' =&gt; array(
              'file_validate_extensions' =&gt; array("png jpg jpeg gif"),
          ),
      );
  }
  </code></pre>
  
  <p>This will allow me to upload and validate an image on the appearance Settings admin screen for this theme. </p>
  
  <p>The file is written to the filesystem as expected. However, the file upload is not marked <code>FILE_STATUS_PERMANENT</code> in the database, causing it to be swept away by the cronjob later. How do I "catch" the results of this file upload so that I can set <code>FILE_STATUS_PERMANENT</code> and get the <code>fid</code> of the <code>managed_file</code> object? I have a feeling it has something to do with <a href="http://api.drupal.org/api/drupal/modules--system--system.admin.inc/function/system_theme_settings_submit/7" rel="nofollow">system_theme_settings_submit()</a> but I am not sure what to override.</p>