title: Copy a file to another directory, in which the file does not exist! PHP
body: <p>I'm trying to copy my file from one directory to another directory( destination in which the file does not exist)</p>
  
  <p>As far as I understood copy function just works if you want to rename and the file already exists in the destination directory; what should I do if the file does not exist in the destination directory?</p>
  
  <p>My attempt:</p>
  
  <pre><code>public function addSlidesToPath()
  {
      $myAddr=$this-&gt;input-&gt;post('addr');
      $src=realpath(BASEPATH.'../uploaded_images').'/'.$myAddr[0];
      $dest="C:\\Slides";
      return copy( $src , $dest. basename($src ));
  }
  </code></pre>
  
  <p>Please let me know if you need more clarification; my code works fine if a file with the same name exists in the destination but if no file with the name, it is not working!</p>
  
  <pre><code>ADDED Here you can see my different attempts:
  
  1)for **copy** without basename the error is "The second argument of copy() function cannot be a directory"
  
  2)for **copy** with basename the error is "The second argument of copy() function cannot be a directory" as well
  
  3)for **move_uploaded_file** with basename there is no error but the result is false!
  
  4)for **move_uploaded_file** without basename there is no error but the result is false!
  </code></pre>
  
  <p>Thanks</p>