Why does file_validate_extensions fail to validate? I'm using the following code for validating and uploading a file from a form:

function request_form_submit($form, &amp;$form_state) {
    $validators = array('file_validate_extensions' =&gt; array('png'));
    $file = file_save_upload('spectrum', $validators);
    if ($file) {
        //do stuff
    }


Uploading works, but I want to allow only png files to be uploaded. The validation part does not work at all, file uploading is always successful no matter which extension the uploaded file has.

I also tried giving a space separated list of extensions to file_validate_extensions as mentioned in the documentation, but that didn't change anything.

Any idea what I'm doing wrong here and why this doesn't work at all?
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['survey']['file-upload'] = array(
  '#type' =&gt; 'file',
  '#prefix' =&gt; '&lt;div class="survey-file-upload"&gt;',
  '#suffix' =&gt; '&lt;/div&gt;&lt;/div&gt;',
  '#description' =&gt; 'Image type PNG/JPG Max Size:2Mb.',
);

function create_survey_form_validate($form, &amp;$form_state){
$save = file_save_upload('file-upload', array('file_validate_extensions' =&gt; array("jpg png")),"public://user_sheets",FILE_EXISTS_RENAME);
  if($save == null){
    form_set_error('file_upload', 'Please select a file');
  }
  else if($save == FALSE){
   form_set_error('file_upload', 'Error in file upload');
  }
}