Theme Settings value dissapears I am trying to create functionality where administrator can upload header image whenever he wants.

I' using hook_form_system_theme_settings_alter in theme-settings.php and altering form like this:

 $form['theme_settings']['background_file'] = array(
        '#type' =&gt; 'managed_file',
        '#title' =&gt; t('Background'),
        '#required' =&gt; TRUE,
        '#upload_location' =&gt; file_default_scheme() . '://public/backgrounds/',
        '#default_value' =&gt; theme_get_setting('background_file'),
        '#upload_validators' =&gt; array(
            'file_validate_extensions' =&gt; array('gif png jpg jpeg'),
        ),
    );


in template.php using hook_preprocess_page and doing this in it:

$fid = theme_get_setting('background_file');
$loaded = file_load($fid);
$variables['background_url'] = file_create_url($loaded-&gt;uri);


and trying to reach $variables['background_url'] from tpl.php file.

When I upload image everything works great, header image is set properly and code has no problem but after a while, I don't really know what happens, for example after 1 day file_load returns FALSE, I just reupload image and everything works fine again.

theme_get_setting('background_file'); always returns file id without problems.

I am missing something? I can't find source of problem.

Thanks.
I think it's because there is a problem in your template.php. Indeed drupal should save your file only temporarly. You have to save your file permenantly with this code

$file = file_load($form_state['values']['background_file']);
$file-&gt;status = FILE_STATUS_PERMANENT;
file_save($file);