title: How to upload file in Drupal 7 with forms?
body: <p>I have troubles with Drupal 7 and file uploading.</p>
  
  <p>My code that doesn't work:</p>
  
  <pre><code>function test_form($form, &amp;$form_state){
  
  $form['#attributes'] = array('enctype' =&gt; "multipart/form-data");
  $form['podcast'] = array(
      '#title' =&gt; 'Audio file',
      '#type' =&gt; 'file',
  );
  $form['submit'] = array(
      '#type' =&gt; 'submit',
      '#value' =&gt; t('Save'),
  );
  return $form;
  
  }
  
  function test_form_submit($form, &amp;$form_state){
  
  $vals = $form_state['values'];
  $filepath = 'public://test/';
  //$filepath = 'temporary://test/';
  $filename = 'rcc_date.mp3';
  
  file_prepare_directory($filepath, FILE_CREATE_DIRECTORY);
  $file = file_save_upload('podcast', array('file_validate_extensions' =&gt; array()), $filepath.$filename);
  //got FALSE here. Why?
  die(print_r($file===FALSE).'-');
  
  }
  </code></pre>
  
  <p>So path created but file doesn't uploads and file_save_upload returns FALSE. Also I tried array() and true as $validators with no effect.</p>
  
  <p>Any help greatly appreciated. Thanks.</p>