title: PHP File Copy Permission Error
body: <p>Why am I getting a permission error on the line were I copy the file across?</p>
  
  <p>I have <code>print_r</code> on  <code>$candidatefile</code> and this shows the full file path and correct name to the new location.</p>
  
  <p><code>$fields['Resume']</code> is blank when I run <code>print_r</code> but the file still uploads to the cache</p>
  
  <p>both folders are <code>777</code></p>
  
  <p>/home/name/mysite0912/cache/resumes/1ZHiYGZj7J.txt Remuse
  /home/name/mysite0912/downloads/cv_folder/new-filename-cv.txt New Location</p>
  
  <p>Everything else is sweet except that</p>
  
  <p><strong>Code Section:</strong></p>
  
  <pre><code>  $candidateuploaddir = _MYSITEDIR . '/downloads/refocus_candidates/';
          $candiatefilename = $fields['RenamedResume'];
          $candidatefile = $candidateuploaddir . $candiatefilename;
  
          if(empty($fields['Resume']))
          {
                  echo 'null';
          }else{
          copy($fields['Resume'],$candiatefilename);
          }
  </code></pre>
  
  <p><strong>Upload Function:</strong></p>
  
  <pre><code>function uploadResume()
  {
      if (!isset($_FILES['UploadResume'])) return false;
      $uploaddir = _CACHEDIR.'/resumes/';
      /* create the upload folder if it does not already exist */
      CMS::RecursiveMkdir($uploaddir);
      $extension = CMS::getFileExtension(basename($_FILES['UploadResume']['name']));
      /* keep producing random filenames until we get a unique one */
      while (empty($filename) || CMS::fileExists($uploaddir.$filename)) {
          $filename = CMS::randomString(10).'.'.$extension;
      }
  
      $uploadfile = $uploaddir . $filename;
  
      if (move_uploaded_file($_FILES['UploadResume']['tmp_name'], $uploadfile)){
  
          return $uploadfile;
          //$uploadfile;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p><strong>On Submit Line:</strong></p>
  
  <pre><code>$fields['Resume'] = CMS::either(CMS_Plugin_plugin_jobs_apply::uploadResume(), CMS::getFormData('Resume', false)); //upload resume to temporary location
  </code></pre>