title: System cannot find the path specified rename file
body: <p>I am trying to rename a file but I get this error.</p>
  
  <pre><code>$newFile = "$surname _$firstname _$dob";
  $string = str_replace(' ', '', $newFile);
  rename($filename, "$string.pdf");
  </code></pre>
  
  <p>This code produces this error</p>
  
  <pre><code>Warning: rename(0001_D_A.pdf,Mccoy_Edward_11/22/2016.pdf): The system cannot find the path specified. (code: 3) in C:\xampp\htdocs\script.php on line 7
  </code></pre>
  
  <p>However if I change the code to use a normal string without a variable it will rename the file without any error.</p>
  
  <pre><code>$newFile = "$surname _$firstname _$dob";
  $string = str_replace(' ', '', $newFile);
  rename($filename, "helloworld");
  </code></pre>
  
  <p>The output from $string is -</p>
  
  <pre><code>Mccoy_Edward_11/22/2016
  </code></pre>