title: move_uploaded_file returns an error code of 0
body: <p>Please see code snippet at the end of this post...</p>
  
  <p>I consistently get back an error code of 0 when attempting to use <code>move_uploaded_file</code> to move a tmp file into another directory.  I've confirmed that the directory exists and the permissions are set to 775 on it.  I've also checked with the server admin and he says he's not seeing any errors in the error log that would explain the issue I'm having.</p>
  
  <p>How do I get around an error code of 0 when using <code>move_uploaded_file</code>?</p>
  
  <pre><code>$audio_dir  = "/mbc/data/audio/";
  
  if (isset($_POST['upload_audio'])) {
  
      $title      = mysql_real_escape_string($_POST['audio_title']);
      $category   = mysql_real_escape_string($_POST['audio_category']);
      $audio_name = basename($_FILES['audio_file']['name']);
      $uploadfile = $audio_dir.$audio_name;
  
      $query = mysql_query("SELECT COUNT(*) FROM media where path = '" . $audio_name . "'");
      $result = mysql_result($query, 0, 0);
  
      if (($title == '') || ($title == NULL) ||
          ($category == '') || ($category == NULL) ||
          ($audio_name == '') || ($audio_name == NULL)) {
          echo "&lt;span class='error'&gt;Title, Category and Audio file are required fields&lt;/span&gt;";                            
      } else if ($result &gt; 0) {
      echo "&lt;span class='error'&gt;Media $audio_name already exists - please upload with a different name&lt;/span&gt;";                               
      } else if (ctype_alpha($category) === false) {
          echo "&lt;span class='error'&gt;Category can only have letters (no spaces, commas, numbers, etc...)&lt;/span&gt;";              
      } else if (ctype_alnum(substr($audio_name, 0, strpos($audio_name, '.'))) === false) {
      echo "&lt;span class='error'&gt;Bad filename - $audio_name - can only contain letters and numbers (i.e. 'HowGreatThouArt.mp3')&lt;/span&gt;";
      } else {
          if (move_uploaded_file($_FILES['audio_file']['tmp_name'], $uploadfile)) {
              $queryInsertAudio = "insert into media (title, path, category ) values ('{$title}','{$audio_name}','{$category}')";
              $result = mysql_query($queryInsertAudio);
              if ($result) {
                  echo "&lt;span class='success'&gt;AUDIO $audio_name UPLOADED SUCCESSFULLY&lt;/span&gt;";
              } else {
                  echo "&lt;span class='error'&gt;FAILED TO INSERT RECORD FOR $audio_name - PLEASE CONTACT ADMINISTRATOR&lt;/span&gt;";
              }
          } else {
              echo "&lt;span class='error'&gt;FAILED TO UPLOAD AUDIO $audio_name - PLEASE CONTACT ADMINISTRATOR&lt;br /&gt;" . 
                   "ERROR CODE = " . $_FILES['audio_file']['error'] . "&lt;br /&gt;" . 
                   "Temp filename=" . $_FILES['audio_file']['tmp_name'] . "&lt;br /&gt;" .
                   "Uploadfile=" . $uploadfile . "&lt;br /&gt;" .
                   print_r($_FILES) . 
                  "&lt;/span&gt;";
          }
      }
  }
  </code></pre>