Error in file_save() I have a config page in my module were you can upload a file and change a few other settings.  It works fine IF you do upload a new file when you click save however if you don't upload a file and just try to change a setting I get this error:

Argument 1 passed to file_save() must be an instance of stdClass, boolean   given, called


The message references an error in the following piece of code:

function background_audio_form_submit($form, $form_state) {

  // The file is automatically uploaded and saved in the default
  // validation process so you just need to load the file object at this  point,
  // mark that you want to keep it, and save it again.
  // The file ID is contained in the $form_state['values'] array
  $file = file_load($form_state['values']['background_audio_file']);
  file_save($file); &lt;-- THIS IS WERE THE ERROR OCCOURS

  variable_set('background_audio_upload_path', $file-&gt;filename);
  variable_set('background_audio_height', $form_state['values']['background_audio_height']);
  variable_set('background_audio_width', $form_state['values']['background_audio_width']);
}


Can I do something like if $file is changed then execute it if it is NOT changed ignore it?    If so how would I do that?
The $form_state array variable contains all the information about the current state of the form. print_r($form_state) to find out the array key corresponding to the upload element in the form. If there is no new upload, this array key should have an empty value, or maybe the array key won't exist at all. If for example $form_state['upload_element'] is populated, then you can call file_save($file);.